
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>turtle — Turtle graphics &#8212; Python 3.7.2 documentation</title>
    <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python 3.7.2 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="next" title="cmd — Support for line-oriented command interpreters" href="cmd.html" />
    <link rel="prev" title="Program Frameworks" href="frameworks.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
    <link rel="canonical" href="https://docs.python.org/3/library/turtle.html" />
    
    <script type="text/javascript" src="../_static/copybutton.js"></script>
    
    
    
    
    <style>
      @media only screen {
        table.full-width-table {
            width: 100%;
        }
      }
    </style>
 

  </head><body>  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="cmd.html" title="cmd — Support for line-oriented command interpreters"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="frameworks.html" title="Program Frameworks"
             accesskey="P">previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <a href="../index.html">3.7.2 Documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="frameworks.html" accesskey="U">Program Frameworks</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" type="text" name="q" />
          <input type="submit" value="Go" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="module-turtle">
<span id="turtle-turtle-graphics"></span><h1><a class="reference internal" href="#module-turtle" title="turtle: An educational framework for simple graphics applications"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a> — Turtle graphics<a class="headerlink" href="#module-turtle" title="Permalink to this headline">¶</a></h1>
<p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.7/Lib/turtle.py">Lib/turtle.py</a></p>
<hr class="docutils" />
<div class="section" id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>Turtle graphics is a popular way for introducing programming to kids.  It was
part of the original Logo programming language developed by Wally Feurzig and
Seymour Papert in 1966.</p>
<p>Imagine a robotic turtle starting at (0, 0) in the x-y plane.  After an <code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">turtle</span></code>, give it the
command <code class="docutils literal notranslate"><span class="pre">turtle.forward(15)</span></code>, and it moves (on-screen!) 15 pixels in the
direction it is facing, drawing a line as it moves.  Give it the command
<code class="docutils literal notranslate"><span class="pre">turtle.right(25)</span></code>, and it rotates in-place 25 degrees clockwise.</p>
<div class="sidebar">
<p class="first sidebar-title">Turtle star</p>
<p>Turtle can draw intricate shapes using programs that repeat simple
moves.</p>
<img alt="../_images/turtle-star.png" class="align-center" src="../_images/turtle-star.png" />
<div class="last highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">turtle</span> <span class="k">import</span> <span class="o">*</span>
<span class="n">color</span><span class="p">(</span><span class="s1">&#39;red&#39;</span><span class="p">,</span> <span class="s1">&#39;yellow&#39;</span><span class="p">)</span>
<span class="n">begin_fill</span><span class="p">()</span>
<span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
    <span class="n">forward</span><span class="p">(</span><span class="mi">200</span><span class="p">)</span>
    <span class="n">left</span><span class="p">(</span><span class="mi">170</span><span class="p">)</span>
    <span class="k">if</span> <span class="nb">abs</span><span class="p">(</span><span class="n">pos</span><span class="p">())</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">:</span>
        <span class="k">break</span>
<span class="n">end_fill</span><span class="p">()</span>
<span class="n">done</span><span class="p">()</span>
</pre></div>
</div>
</div>
<p>By combining together these and similar commands, intricate shapes and pictures
can easily be drawn.</p>
<p>The <a class="reference internal" href="#module-turtle" title="turtle: An educational framework for simple graphics applications"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a> module is an extended reimplementation of the same-named
module from the Python standard distribution up to version Python 2.5.</p>
<p>It tries to keep the merits of the old turtle module and to be (nearly) 100%
compatible with it.  This means in the first place to enable the learning
programmer to use all the commands, classes and methods interactively when using
the module from within IDLE run with the <code class="docutils literal notranslate"><span class="pre">-n</span></code> switch.</p>
<p>The turtle module provides turtle graphics primitives, in both object-oriented
and procedure-oriented ways.  Because it uses <a class="reference internal" href="tkinter.html#module-tkinter" title="tkinter: Interface to Tcl/Tk for graphical user interfaces"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code></a> for the underlying
graphics, it needs a version of Python installed with Tk support.</p>
<p>The object-oriented interface uses essentially two+two classes:</p>
<ol class="arabic">
<li><p class="first">The <a class="reference internal" href="#turtle.TurtleScreen" title="turtle.TurtleScreen"><code class="xref py py-class docutils literal notranslate"><span class="pre">TurtleScreen</span></code></a> class defines graphics windows as a playground for
the drawing turtles.  Its constructor needs a <code class="xref py py-class docutils literal notranslate"><span class="pre">tkinter.Canvas</span></code> or a
<a class="reference internal" href="#turtle.ScrolledCanvas" title="turtle.ScrolledCanvas"><code class="xref py py-class docutils literal notranslate"><span class="pre">ScrolledCanvas</span></code></a> as argument.  It should be used when <a class="reference internal" href="#module-turtle" title="turtle: An educational framework for simple graphics applications"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a> is
used as part of some application.</p>
<p>The function <a class="reference internal" href="#turtle.Screen" title="turtle.Screen"><code class="xref py py-func docutils literal notranslate"><span class="pre">Screen()</span></code></a> returns a singleton object of a
<a class="reference internal" href="#turtle.TurtleScreen" title="turtle.TurtleScreen"><code class="xref py py-class docutils literal notranslate"><span class="pre">TurtleScreen</span></code></a> subclass. This function should be used when
<a class="reference internal" href="#module-turtle" title="turtle: An educational framework for simple graphics applications"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a> is used as a standalone tool for doing graphics.
As a singleton object, inheriting from its class is not possible.</p>
<p>All methods of TurtleScreen/Screen also exist as functions, i.e. as part of
the procedure-oriented interface.</p>
</li>
<li><p class="first"><a class="reference internal" href="#turtle.RawTurtle" title="turtle.RawTurtle"><code class="xref py py-class docutils literal notranslate"><span class="pre">RawTurtle</span></code></a> (alias: <a class="reference internal" href="#turtle.RawPen" title="turtle.RawPen"><code class="xref py py-class docutils literal notranslate"><span class="pre">RawPen</span></code></a>) defines Turtle objects which draw
on a <a class="reference internal" href="#turtle.TurtleScreen" title="turtle.TurtleScreen"><code class="xref py py-class docutils literal notranslate"><span class="pre">TurtleScreen</span></code></a>.  Its constructor needs a Canvas, ScrolledCanvas
or TurtleScreen as argument, so the RawTurtle objects know where to draw.</p>
<p>Derived from RawTurtle is the subclass <a class="reference internal" href="#turtle.Turtle" title="turtle.Turtle"><code class="xref py py-class docutils literal notranslate"><span class="pre">Turtle</span></code></a> (alias: <code class="xref py py-class docutils literal notranslate"><span class="pre">Pen</span></code>),
which draws on “the” <a class="reference internal" href="#turtle.Screen" title="turtle.Screen"><code class="xref py py-class docutils literal notranslate"><span class="pre">Screen</span></code></a> instance which is automatically
created, if not already present.</p>
<p>All methods of RawTurtle/Turtle also exist as functions, i.e. part of the
procedure-oriented interface.</p>
</li>
</ol>
<p>The procedural interface provides functions which are derived from the methods
of the classes <a class="reference internal" href="#turtle.Screen" title="turtle.Screen"><code class="xref py py-class docutils literal notranslate"><span class="pre">Screen</span></code></a> and <a class="reference internal" href="#turtle.Turtle" title="turtle.Turtle"><code class="xref py py-class docutils literal notranslate"><span class="pre">Turtle</span></code></a>.  They have the same names as
the corresponding methods.  A screen object is automatically created whenever a
function derived from a Screen method is called.  An (unnamed) turtle object is
automatically created whenever any of the functions derived from a Turtle method
is called.</p>
<p>To use multiple turtles on a screen one has to use the object-oriented interface.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">In the following documentation the argument list for functions is given.
Methods, of course, have the additional first argument <em>self</em> which is
omitted here.</p>
</div>
</div>
<div class="section" id="overview-of-available-turtle-and-screen-methods">
<h2>Overview of available Turtle and Screen methods<a class="headerlink" href="#overview-of-available-turtle-and-screen-methods" title="Permalink to this headline">¶</a></h2>
<div class="section" id="turtle-methods">
<h3>Turtle methods<a class="headerlink" href="#turtle-methods" title="Permalink to this headline">¶</a></h3>
<dl class="docutils">
<dt>Turtle motion</dt>
<dd><dl class="first last docutils">
<dt>Move and draw</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.forward" title="turtle.forward"><code class="xref py py-func docutils literal notranslate"><span class="pre">forward()</span></code></a> | <a class="reference internal" href="#turtle.fd" title="turtle.fd"><code class="xref py py-func docutils literal notranslate"><span class="pre">fd()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.backward" title="turtle.backward"><code class="xref py py-func docutils literal notranslate"><span class="pre">backward()</span></code></a> | <a class="reference internal" href="#turtle.bk" title="turtle.bk"><code class="xref py py-func docutils literal notranslate"><span class="pre">bk()</span></code></a> | <a class="reference internal" href="#turtle.back" title="turtle.back"><code class="xref py py-func docutils literal notranslate"><span class="pre">back()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.right" title="turtle.right"><code class="xref py py-func docutils literal notranslate"><span class="pre">right()</span></code></a> | <a class="reference internal" href="#turtle.rt" title="turtle.rt"><code class="xref py py-func docutils literal notranslate"><span class="pre">rt()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.left" title="turtle.left"><code class="xref py py-func docutils literal notranslate"><span class="pre">left()</span></code></a> | <a class="reference internal" href="#turtle.lt" title="turtle.lt"><code class="xref py py-func docutils literal notranslate"><span class="pre">lt()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.goto" title="turtle.goto"><code class="xref py py-func docutils literal notranslate"><span class="pre">goto()</span></code></a> | <a class="reference internal" href="#turtle.setpos" title="turtle.setpos"><code class="xref py py-func docutils literal notranslate"><span class="pre">setpos()</span></code></a> | <a class="reference internal" href="#turtle.setposition" title="turtle.setposition"><code class="xref py py-func docutils literal notranslate"><span class="pre">setposition()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.setx" title="turtle.setx"><code class="xref py py-func docutils literal notranslate"><span class="pre">setx()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.sety" title="turtle.sety"><code class="xref py py-func docutils literal notranslate"><span class="pre">sety()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.setheading" title="turtle.setheading"><code class="xref py py-func docutils literal notranslate"><span class="pre">setheading()</span></code></a> | <a class="reference internal" href="#turtle.seth" title="turtle.seth"><code class="xref py py-func docutils literal notranslate"><span class="pre">seth()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.home" title="turtle.home"><code class="xref py py-func docutils literal notranslate"><span class="pre">home()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.circle" title="turtle.circle"><code class="xref py py-func docutils literal notranslate"><span class="pre">circle()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.dot" title="turtle.dot"><code class="xref py py-func docutils literal notranslate"><span class="pre">dot()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.stamp" title="turtle.stamp"><code class="xref py py-func docutils literal notranslate"><span class="pre">stamp()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.clearstamp" title="turtle.clearstamp"><code class="xref py py-func docutils literal notranslate"><span class="pre">clearstamp()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.clearstamps" title="turtle.clearstamps"><code class="xref py py-func docutils literal notranslate"><span class="pre">clearstamps()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.undo" title="turtle.undo"><code class="xref py py-func docutils literal notranslate"><span class="pre">undo()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.speed" title="turtle.speed"><code class="xref py py-func docutils literal notranslate"><span class="pre">speed()</span></code></a></div>
</div>
</dd>
<dt>Tell Turtle’s state</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.position" title="turtle.position"><code class="xref py py-func docutils literal notranslate"><span class="pre">position()</span></code></a> | <a class="reference internal" href="#turtle.pos" title="turtle.pos"><code class="xref py py-func docutils literal notranslate"><span class="pre">pos()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.towards" title="turtle.towards"><code class="xref py py-func docutils literal notranslate"><span class="pre">towards()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.xcor" title="turtle.xcor"><code class="xref py py-func docutils literal notranslate"><span class="pre">xcor()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.ycor" title="turtle.ycor"><code class="xref py py-func docutils literal notranslate"><span class="pre">ycor()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.heading" title="turtle.heading"><code class="xref py py-func docutils literal notranslate"><span class="pre">heading()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.distance" title="turtle.distance"><code class="xref py py-func docutils literal notranslate"><span class="pre">distance()</span></code></a></div>
</div>
</dd>
<dt>Setting and measurement</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.degrees" title="turtle.degrees"><code class="xref py py-func docutils literal notranslate"><span class="pre">degrees()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.radians" title="turtle.radians"><code class="xref py py-func docutils literal notranslate"><span class="pre">radians()</span></code></a></div>
</div>
</dd>
</dl>
</dd>
<dt>Pen control</dt>
<dd><dl class="first last docutils">
<dt>Drawing state</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.pendown" title="turtle.pendown"><code class="xref py py-func docutils literal notranslate"><span class="pre">pendown()</span></code></a> | <a class="reference internal" href="#turtle.pd" title="turtle.pd"><code class="xref py py-func docutils literal notranslate"><span class="pre">pd()</span></code></a> | <a class="reference internal" href="#turtle.down" title="turtle.down"><code class="xref py py-func docutils literal notranslate"><span class="pre">down()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.penup" title="turtle.penup"><code class="xref py py-func docutils literal notranslate"><span class="pre">penup()</span></code></a> | <a class="reference internal" href="#turtle.pu" title="turtle.pu"><code class="xref py py-func docutils literal notranslate"><span class="pre">pu()</span></code></a> | <a class="reference internal" href="#turtle.up" title="turtle.up"><code class="xref py py-func docutils literal notranslate"><span class="pre">up()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.pensize" title="turtle.pensize"><code class="xref py py-func docutils literal notranslate"><span class="pre">pensize()</span></code></a> | <a class="reference internal" href="#turtle.width" title="turtle.width"><code class="xref py py-func docutils literal notranslate"><span class="pre">width()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.pen" title="turtle.pen"><code class="xref py py-func docutils literal notranslate"><span class="pre">pen()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.isdown" title="turtle.isdown"><code class="xref py py-func docutils literal notranslate"><span class="pre">isdown()</span></code></a></div>
</div>
</dd>
<dt>Color control</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.color" title="turtle.color"><code class="xref py py-func docutils literal notranslate"><span class="pre">color()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.pencolor" title="turtle.pencolor"><code class="xref py py-func docutils literal notranslate"><span class="pre">pencolor()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.fillcolor" title="turtle.fillcolor"><code class="xref py py-func docutils literal notranslate"><span class="pre">fillcolor()</span></code></a></div>
</div>
</dd>
<dt>Filling</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.filling" title="turtle.filling"><code class="xref py py-func docutils literal notranslate"><span class="pre">filling()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.begin_fill" title="turtle.begin_fill"><code class="xref py py-func docutils literal notranslate"><span class="pre">begin_fill()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.end_fill" title="turtle.end_fill"><code class="xref py py-func docutils literal notranslate"><span class="pre">end_fill()</span></code></a></div>
</div>
</dd>
<dt>More drawing control</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.reset" title="turtle.reset"><code class="xref py py-func docutils literal notranslate"><span class="pre">reset()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.clear" title="turtle.clear"><code class="xref py py-func docutils literal notranslate"><span class="pre">clear()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.write" title="turtle.write"><code class="xref py py-func docutils literal notranslate"><span class="pre">write()</span></code></a></div>
</div>
</dd>
</dl>
</dd>
<dt>Turtle state</dt>
<dd><dl class="first last docutils">
<dt>Visibility</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.showturtle" title="turtle.showturtle"><code class="xref py py-func docutils literal notranslate"><span class="pre">showturtle()</span></code></a> | <a class="reference internal" href="#turtle.st" title="turtle.st"><code class="xref py py-func docutils literal notranslate"><span class="pre">st()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.hideturtle" title="turtle.hideturtle"><code class="xref py py-func docutils literal notranslate"><span class="pre">hideturtle()</span></code></a> | <a class="reference internal" href="#turtle.ht" title="turtle.ht"><code class="xref py py-func docutils literal notranslate"><span class="pre">ht()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.isvisible" title="turtle.isvisible"><code class="xref py py-func docutils literal notranslate"><span class="pre">isvisible()</span></code></a></div>
</div>
</dd>
<dt>Appearance</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.shape" title="turtle.shape"><code class="xref py py-func docutils literal notranslate"><span class="pre">shape()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.resizemode" title="turtle.resizemode"><code class="xref py py-func docutils literal notranslate"><span class="pre">resizemode()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.shapesize" title="turtle.shapesize"><code class="xref py py-func docutils literal notranslate"><span class="pre">shapesize()</span></code></a> | <a class="reference internal" href="#turtle.turtlesize" title="turtle.turtlesize"><code class="xref py py-func docutils literal notranslate"><span class="pre">turtlesize()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.shearfactor" title="turtle.shearfactor"><code class="xref py py-func docutils literal notranslate"><span class="pre">shearfactor()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.settiltangle" title="turtle.settiltangle"><code class="xref py py-func docutils literal notranslate"><span class="pre">settiltangle()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.tiltangle" title="turtle.tiltangle"><code class="xref py py-func docutils literal notranslate"><span class="pre">tiltangle()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.tilt" title="turtle.tilt"><code class="xref py py-func docutils literal notranslate"><span class="pre">tilt()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.shapetransform" title="turtle.shapetransform"><code class="xref py py-func docutils literal notranslate"><span class="pre">shapetransform()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.get_shapepoly" title="turtle.get_shapepoly"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_shapepoly()</span></code></a></div>
</div>
</dd>
</dl>
</dd>
<dt>Using events</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.onclick" title="turtle.onclick"><code class="xref py py-func docutils literal notranslate"><span class="pre">onclick()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.onrelease" title="turtle.onrelease"><code class="xref py py-func docutils literal notranslate"><span class="pre">onrelease()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.ondrag" title="turtle.ondrag"><code class="xref py py-func docutils literal notranslate"><span class="pre">ondrag()</span></code></a></div>
</div>
</dd>
<dt>Special Turtle methods</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.begin_poly" title="turtle.begin_poly"><code class="xref py py-func docutils literal notranslate"><span class="pre">begin_poly()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.end_poly" title="turtle.end_poly"><code class="xref py py-func docutils literal notranslate"><span class="pre">end_poly()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.get_poly" title="turtle.get_poly"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_poly()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.clone" title="turtle.clone"><code class="xref py py-func docutils literal notranslate"><span class="pre">clone()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.getturtle" title="turtle.getturtle"><code class="xref py py-func docutils literal notranslate"><span class="pre">getturtle()</span></code></a> | <a class="reference internal" href="#turtle.getpen" title="turtle.getpen"><code class="xref py py-func docutils literal notranslate"><span class="pre">getpen()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.getscreen" title="turtle.getscreen"><code class="xref py py-func docutils literal notranslate"><span class="pre">getscreen()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.setundobuffer" title="turtle.setundobuffer"><code class="xref py py-func docutils literal notranslate"><span class="pre">setundobuffer()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.undobufferentries" title="turtle.undobufferentries"><code class="xref py py-func docutils literal notranslate"><span class="pre">undobufferentries()</span></code></a></div>
</div>
</dd>
</dl>
</div>
<div class="section" id="methods-of-turtlescreen-screen">
<h3>Methods of TurtleScreen/Screen<a class="headerlink" href="#methods-of-turtlescreen-screen" title="Permalink to this headline">¶</a></h3>
<dl class="docutils">
<dt>Window control</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.bgcolor" title="turtle.bgcolor"><code class="xref py py-func docutils literal notranslate"><span class="pre">bgcolor()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.bgpic" title="turtle.bgpic"><code class="xref py py-func docutils literal notranslate"><span class="pre">bgpic()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.clear" title="turtle.clear"><code class="xref py py-func docutils literal notranslate"><span class="pre">clear()</span></code></a> | <a class="reference internal" href="#turtle.clearscreen" title="turtle.clearscreen"><code class="xref py py-func docutils literal notranslate"><span class="pre">clearscreen()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.reset" title="turtle.reset"><code class="xref py py-func docutils literal notranslate"><span class="pre">reset()</span></code></a> | <a class="reference internal" href="#turtle.resetscreen" title="turtle.resetscreen"><code class="xref py py-func docutils literal notranslate"><span class="pre">resetscreen()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.screensize" title="turtle.screensize"><code class="xref py py-func docutils literal notranslate"><span class="pre">screensize()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.setworldcoordinates" title="turtle.setworldcoordinates"><code class="xref py py-func docutils literal notranslate"><span class="pre">setworldcoordinates()</span></code></a></div>
</div>
</dd>
<dt>Animation control</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.delay" title="turtle.delay"><code class="xref py py-func docutils literal notranslate"><span class="pre">delay()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.tracer" title="turtle.tracer"><code class="xref py py-func docutils literal notranslate"><span class="pre">tracer()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.update" title="turtle.update"><code class="xref py py-func docutils literal notranslate"><span class="pre">update()</span></code></a></div>
</div>
</dd>
<dt>Using screen events</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.listen" title="turtle.listen"><code class="xref py py-func docutils literal notranslate"><span class="pre">listen()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.onkey" title="turtle.onkey"><code class="xref py py-func docutils literal notranslate"><span class="pre">onkey()</span></code></a> | <a class="reference internal" href="#turtle.onkeyrelease" title="turtle.onkeyrelease"><code class="xref py py-func docutils literal notranslate"><span class="pre">onkeyrelease()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.onkeypress" title="turtle.onkeypress"><code class="xref py py-func docutils literal notranslate"><span class="pre">onkeypress()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.onclick" title="turtle.onclick"><code class="xref py py-func docutils literal notranslate"><span class="pre">onclick()</span></code></a> | <a class="reference internal" href="#turtle.onscreenclick" title="turtle.onscreenclick"><code class="xref py py-func docutils literal notranslate"><span class="pre">onscreenclick()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.ontimer" title="turtle.ontimer"><code class="xref py py-func docutils literal notranslate"><span class="pre">ontimer()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.mainloop" title="turtle.mainloop"><code class="xref py py-func docutils literal notranslate"><span class="pre">mainloop()</span></code></a> | <a class="reference internal" href="#turtle.done" title="turtle.done"><code class="xref py py-func docutils literal notranslate"><span class="pre">done()</span></code></a></div>
</div>
</dd>
<dt>Settings and special methods</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.mode" title="turtle.mode"><code class="xref py py-func docutils literal notranslate"><span class="pre">mode()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.colormode" title="turtle.colormode"><code class="xref py py-func docutils literal notranslate"><span class="pre">colormode()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.getcanvas" title="turtle.getcanvas"><code class="xref py py-func docutils literal notranslate"><span class="pre">getcanvas()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.getshapes" title="turtle.getshapes"><code class="xref py py-func docutils literal notranslate"><span class="pre">getshapes()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.register_shape" title="turtle.register_shape"><code class="xref py py-func docutils literal notranslate"><span class="pre">register_shape()</span></code></a> | <a class="reference internal" href="#turtle.addshape" title="turtle.addshape"><code class="xref py py-func docutils literal notranslate"><span class="pre">addshape()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.turtles" title="turtle.turtles"><code class="xref py py-func docutils literal notranslate"><span class="pre">turtles()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.window_height" title="turtle.window_height"><code class="xref py py-func docutils literal notranslate"><span class="pre">window_height()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.window_width" title="turtle.window_width"><code class="xref py py-func docutils literal notranslate"><span class="pre">window_width()</span></code></a></div>
</div>
</dd>
<dt>Input methods</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.textinput" title="turtle.textinput"><code class="xref py py-func docutils literal notranslate"><span class="pre">textinput()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.numinput" title="turtle.numinput"><code class="xref py py-func docutils literal notranslate"><span class="pre">numinput()</span></code></a></div>
</div>
</dd>
<dt>Methods specific to Screen</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.bye" title="turtle.bye"><code class="xref py py-func docutils literal notranslate"><span class="pre">bye()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.exitonclick" title="turtle.exitonclick"><code class="xref py py-func docutils literal notranslate"><span class="pre">exitonclick()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.setup" title="turtle.setup"><code class="xref py py-func docutils literal notranslate"><span class="pre">setup()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.title" title="turtle.title"><code class="xref py py-func docutils literal notranslate"><span class="pre">title()</span></code></a></div>
</div>
</dd>
</dl>
</div>
</div>
<div class="section" id="methods-of-rawturtle-turtle-and-corresponding-functions">
<h2>Methods of RawTurtle/Turtle and corresponding functions<a class="headerlink" href="#methods-of-rawturtle-turtle-and-corresponding-functions" title="Permalink to this headline">¶</a></h2>
<p>Most of the examples in this section refer to a Turtle instance called
<code class="docutils literal notranslate"><span class="pre">turtle</span></code>.</p>
<div class="section" id="turtle-motion">
<h3>Turtle motion<a class="headerlink" href="#turtle-motion" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.forward">
<code class="descclassname">turtle.</code><code class="descname">forward</code><span class="sig-paren">(</span><em>distance</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.forward" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.fd">
<code class="descclassname">turtle.</code><code class="descname">fd</code><span class="sig-paren">(</span><em>distance</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.fd" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>distance</strong> – a number (integer or float)</td>
</tr>
</tbody>
</table>
<p>Move the turtle forward by the specified <em>distance</em>, in the direction the
turtle is headed.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="mi">25</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(25.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="o">-</span><span class="mi">75</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(-50.00,0.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.back">
<code class="descclassname">turtle.</code><code class="descname">back</code><span class="sig-paren">(</span><em>distance</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.back" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.bk">
<code class="descclassname">turtle.</code><code class="descname">bk</code><span class="sig-paren">(</span><em>distance</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.bk" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.backward">
<code class="descclassname">turtle.</code><code class="descname">backward</code><span class="sig-paren">(</span><em>distance</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.backward" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>distance</strong> – a number</td>
</tr>
</tbody>
</table>
<p>Move the turtle backward by <em>distance</em>, opposite to the direction the
turtle is headed.  Do not change the turtle’s heading.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">backward</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(-30.00,0.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.right">
<code class="descclassname">turtle.</code><code class="descname">right</code><span class="sig-paren">(</span><em>angle</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.right" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.rt">
<code class="descclassname">turtle.</code><code class="descname">rt</code><span class="sig-paren">(</span><em>angle</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.rt" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>angle</strong> – a number (integer or float)</td>
</tr>
</tbody>
</table>
<p>Turn turtle right by <em>angle</em> units.  (Units are by default degrees, but
can be set via the <a class="reference internal" href="#turtle.degrees" title="turtle.degrees"><code class="xref py py-func docutils literal notranslate"><span class="pre">degrees()</span></code></a> and <a class="reference internal" href="#turtle.radians" title="turtle.radians"><code class="xref py py-func docutils literal notranslate"><span class="pre">radians()</span></code></a> functions.)  Angle
orientation depends on the turtle mode, see <a class="reference internal" href="#turtle.mode" title="turtle.mode"><code class="xref py py-func docutils literal notranslate"><span class="pre">mode()</span></code></a>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">22.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">right</span><span class="p">(</span><span class="mi">45</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">337.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.left">
<code class="descclassname">turtle.</code><code class="descname">left</code><span class="sig-paren">(</span><em>angle</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.left" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.lt">
<code class="descclassname">turtle.</code><code class="descname">lt</code><span class="sig-paren">(</span><em>angle</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.lt" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>angle</strong> – a number (integer or float)</td>
</tr>
</tbody>
</table>
<p>Turn turtle left by <em>angle</em> units.  (Units are by default degrees, but
can be set via the <a class="reference internal" href="#turtle.degrees" title="turtle.degrees"><code class="xref py py-func docutils literal notranslate"><span class="pre">degrees()</span></code></a> and <a class="reference internal" href="#turtle.radians" title="turtle.radians"><code class="xref py py-func docutils literal notranslate"><span class="pre">radians()</span></code></a> functions.)  Angle
orientation depends on the turtle mode, see <a class="reference internal" href="#turtle.mode" title="turtle.mode"><code class="xref py py-func docutils literal notranslate"><span class="pre">mode()</span></code></a>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">22.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">45</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">67.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.goto">
<code class="descclassname">turtle.</code><code class="descname">goto</code><span class="sig-paren">(</span><em>x</em>, <em>y=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.goto" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.setpos">
<code class="descclassname">turtle.</code><code class="descname">setpos</code><span class="sig-paren">(</span><em>x</em>, <em>y=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.setpos" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.setposition">
<code class="descclassname">turtle.</code><code class="descname">setposition</code><span class="sig-paren">(</span><em>x</em>, <em>y=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.setposition" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>x</strong> – a number or a pair/vector of numbers</li>
<li><strong>y</strong> – a number or <code class="docutils literal notranslate"><span class="pre">None</span></code></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>If <em>y</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>, <em>x</em> must be a pair of coordinates or a <a class="reference internal" href="#turtle.Vec2D" title="turtle.Vec2D"><code class="xref py py-class docutils literal notranslate"><span class="pre">Vec2D</span></code></a>
(e.g. as returned by <a class="reference internal" href="#turtle.pos" title="turtle.pos"><code class="xref py py-func docutils literal notranslate"><span class="pre">pos()</span></code></a>).</p>
<p>Move turtle to an absolute position.  If the pen is down, draw line.  Do
not change the turtle’s orientation.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">tp</span> <span class="o">=</span> <span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">tp</span>
<span class="go">(0.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setpos</span><span class="p">(</span><span class="mi">60</span><span class="p">,</span><span class="mi">30</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(60.00,30.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setpos</span><span class="p">((</span><span class="mi">20</span><span class="p">,</span><span class="mi">80</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(20.00,80.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setpos</span><span class="p">(</span><span class="n">tp</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(0.00,0.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.setx">
<code class="descclassname">turtle.</code><code class="descname">setx</code><span class="sig-paren">(</span><em>x</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.setx" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>x</strong> – a number (integer or float)</td>
</tr>
</tbody>
</table>
<p>Set the turtle’s first coordinate to <em>x</em>, leave second coordinate
unchanged.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,240.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setx</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(10.00,240.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.sety">
<code class="descclassname">turtle.</code><code class="descname">sety</code><span class="sig-paren">(</span><em>y</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.sety" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>y</strong> – a number (integer or float)</td>
</tr>
</tbody>
</table>
<p>Set the turtle’s second coordinate to <em>y</em>, leave first coordinate unchanged.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,40.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">sety</span><span class="p">(</span><span class="o">-</span><span class="mi">10</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,-10.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.setheading">
<code class="descclassname">turtle.</code><code class="descname">setheading</code><span class="sig-paren">(</span><em>to_angle</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.setheading" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.seth">
<code class="descclassname">turtle.</code><code class="descname">seth</code><span class="sig-paren">(</span><em>to_angle</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.seth" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>to_angle</strong> – a number (integer or float)</td>
</tr>
</tbody>
</table>
<p>Set the orientation of the turtle to <em>to_angle</em>.  Here are some common
directions in degrees:</p>
<table border="1" class="docutils">
<colgroup>
<col width="49%" />
<col width="51%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">standard mode</th>
<th class="head">logo mode</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>0 - east</td>
<td>0 - north</td>
</tr>
<tr class="row-odd"><td>90 - north</td>
<td>90 - east</td>
</tr>
<tr class="row-even"><td>180 - west</td>
<td>180 - south</td>
</tr>
<tr class="row-odd"><td>270 - south</td>
<td>270 - west</td>
</tr>
</tbody>
</table>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setheading</span><span class="p">(</span><span class="mi">90</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">90.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.home">
<code class="descclassname">turtle.</code><code class="descname">home</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.home" title="Permalink to this definition">¶</a></dt>
<dd><p>Move turtle to the origin – coordinates (0,0) – and set its heading to
its start-orientation (which depends on the mode, see <a class="reference internal" href="#turtle.mode" title="turtle.mode"><code class="xref py py-func docutils literal notranslate"><span class="pre">mode()</span></code></a>).</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">90.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,-10.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">0.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.circle">
<code class="descclassname">turtle.</code><code class="descname">circle</code><span class="sig-paren">(</span><em>radius</em>, <em>extent=None</em>, <em>steps=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.circle" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>radius</strong> – a number</li>
<li><strong>extent</strong> – a number (or <code class="docutils literal notranslate"><span class="pre">None</span></code>)</li>
<li><strong>steps</strong> – an integer (or <code class="docutils literal notranslate"><span class="pre">None</span></code>)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Draw a circle with given <em>radius</em>.  The center is <em>radius</em> units left of
the turtle; <em>extent</em> – an angle – determines which part of the circle
is drawn.  If <em>extent</em> is not given, draw the entire circle.  If <em>extent</em>
is not a full circle, one endpoint of the arc is the current pen
position.  Draw the arc in counterclockwise direction if <em>radius</em> is
positive, otherwise in clockwise direction.  Finally the direction of the
turtle is changed by the amount of <em>extent</em>.</p>
<p>As the circle is approximated by an inscribed regular polygon, <em>steps</em>
determines the number of steps to use.  If not given, it will be
calculated automatically.  May be used to draw regular polygons.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">0.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">circle</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(-0.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">0.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">circle</span><span class="p">(</span><span class="mi">120</span><span class="p">,</span> <span class="mi">180</span><span class="p">)</span>  <span class="c1"># draw a semicircle</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,240.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">180.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.dot">
<code class="descclassname">turtle.</code><code class="descname">dot</code><span class="sig-paren">(</span><em>size=None</em>, <em>*color</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.dot" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>size</strong> – an integer &gt;= 1 (if given)</li>
<li><strong>color</strong> – a colorstring or a numeric color tuple</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Draw a circular dot with diameter <em>size</em>, using <em>color</em>.  If <em>size</em> is
not given, the maximum of pensize+4 and 2*pensize is used.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">dot</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">);</span> <span class="n">turtle</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="s2">&quot;blue&quot;</span><span class="p">);</span> <span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(100.00,-0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">0.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.stamp">
<code class="descclassname">turtle.</code><code class="descname">stamp</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.stamp" title="Permalink to this definition">¶</a></dt>
<dd><p>Stamp a copy of the turtle shape onto the canvas at the current turtle
position.  Return a stamp_id for that stamp, which can be used to delete
it by calling <code class="docutils literal notranslate"><span class="pre">clearstamp(stamp_id)</span></code>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s2">&quot;blue&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">stamp</span><span class="p">()</span>
<span class="go">11</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.clearstamp">
<code class="descclassname">turtle.</code><code class="descname">clearstamp</code><span class="sig-paren">(</span><em>stampid</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.clearstamp" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>stampid</strong> – an integer, must be return value of previous
<a class="reference internal" href="#turtle.stamp" title="turtle.stamp"><code class="xref py py-func docutils literal notranslate"><span class="pre">stamp()</span></code></a> call</td>
</tr>
</tbody>
</table>
<p>Delete stamp with given <em>stampid</em>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(150.00,-0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s2">&quot;blue&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">astamp</span> <span class="o">=</span> <span class="n">turtle</span><span class="o">.</span><span class="n">stamp</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(200.00,-0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">clearstamp</span><span class="p">(</span><span class="n">astamp</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(200.00,-0.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.clearstamps">
<code class="descclassname">turtle.</code><code class="descname">clearstamps</code><span class="sig-paren">(</span><em>n=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.clearstamps" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>n</strong> – an integer (or <code class="docutils literal notranslate"><span class="pre">None</span></code>)</td>
</tr>
</tbody>
</table>
<p>Delete all or first/last <em>n</em> of turtle’s stamps.  If <em>n</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>, delete
all stamps, if <em>n</em> &gt; 0 delete first <em>n</em> stamps, else if <em>n</em> &lt; 0 delete
last <em>n</em> stamps.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">8</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">turtle</span><span class="o">.</span><span class="n">stamp</span><span class="p">();</span> <span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span>
<span class="go">13</span>
<span class="go">14</span>
<span class="go">15</span>
<span class="go">16</span>
<span class="go">17</span>
<span class="go">18</span>
<span class="go">19</span>
<span class="go">20</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">clearstamps</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">clearstamps</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">clearstamps</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.undo">
<code class="descclassname">turtle.</code><code class="descname">undo</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.undo" title="Permalink to this definition">¶</a></dt>
<dd><p>Undo (repeatedly) the last turtle action(s).  Number of available
undo actions is determined by the size of the undobuffer.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">4</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">);</span> <span class="n">turtle</span><span class="o">.</span><span class="n">lt</span><span class="p">(</span><span class="mi">80</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">8</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">turtle</span><span class="o">.</span><span class="n">undo</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.speed">
<code class="descclassname">turtle.</code><code class="descname">speed</code><span class="sig-paren">(</span><em>speed=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.speed" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>speed</strong> – an integer in the range 0..10 or a speedstring (see below)</td>
</tr>
</tbody>
</table>
<p>Set the turtle’s speed to an integer value in the range 0..10.  If no
argument is given, return current speed.</p>
<p>If input is a number greater than 10 or smaller than 0.5, speed is set
to 0.  Speedstrings are mapped to speedvalues as follows:</p>
<ul class="simple">
<li>“fastest”:  0</li>
<li>“fast”:  10</li>
<li>“normal”:  6</li>
<li>“slow”:  3</li>
<li>“slowest”:  1</li>
</ul>
<p>Speeds from 1 to 10 enforce increasingly faster animation of line drawing
and turtle turning.</p>
<p>Attention: <em>speed</em> = 0 means that <em>no</em> animation takes
place. forward/back makes turtle jump and likewise left/right make the
turtle turn instantly.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">speed</span><span class="p">()</span>
<span class="go">3</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">speed</span><span class="p">(</span><span class="s1">&#39;normal&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">speed</span><span class="p">()</span>
<span class="go">6</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">speed</span><span class="p">(</span><span class="mi">9</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">speed</span><span class="p">()</span>
<span class="go">9</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="tell-turtle-s-state">
<h3>Tell Turtle’s state<a class="headerlink" href="#tell-turtle-s-state" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.position">
<code class="descclassname">turtle.</code><code class="descname">position</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.position" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.pos">
<code class="descclassname">turtle.</code><code class="descname">pos</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.pos" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the turtle’s current location (x,y) (as a <a class="reference internal" href="#turtle.Vec2D" title="turtle.Vec2D"><code class="xref py py-class docutils literal notranslate"><span class="pre">Vec2D</span></code></a> vector).</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(440.00,-0.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.towards">
<code class="descclassname">turtle.</code><code class="descname">towards</code><span class="sig-paren">(</span><em>x</em>, <em>y=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.towards" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>x</strong> – a number or a pair/vector of numbers or a turtle instance</li>
<li><strong>y</strong> – a number if <em>x</em> is a number, else <code class="docutils literal notranslate"><span class="pre">None</span></code></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Return the angle between the line from turtle position to position specified
by (x,y), the vector or the other turtle.  This depends on the turtle’s start
orientation which depends on the mode - “standard”/”world” or “logo”).</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">goto</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">towards</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
<span class="go">225.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.xcor">
<code class="descclassname">turtle.</code><code class="descname">xcor</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.xcor" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the turtle’s x coordinate.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(64.28,76.60)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span><span class="p">(</span><span class="nb">round</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">xcor</span><span class="p">(),</span> <span class="mi">5</span><span class="p">))</span>
<span class="go">64.27876</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.ycor">
<code class="descclassname">turtle.</code><code class="descname">ycor</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.ycor" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the turtle’s y coordinate.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">60</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">())</span>
<span class="go">(50.00,86.60)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span><span class="p">(</span><span class="nb">round</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">ycor</span><span class="p">(),</span> <span class="mi">5</span><span class="p">))</span>
<span class="go">86.60254</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.heading">
<code class="descclassname">turtle.</code><code class="descname">heading</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.heading" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the turtle’s current heading (value depends on the turtle mode, see
<a class="reference internal" href="#turtle.mode" title="turtle.mode"><code class="xref py py-func docutils literal notranslate"><span class="pre">mode()</span></code></a>).</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">67</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">67.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.distance">
<code class="descclassname">turtle.</code><code class="descname">distance</code><span class="sig-paren">(</span><em>x</em>, <em>y=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.distance" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>x</strong> – a number or a pair/vector of numbers or a turtle instance</li>
<li><strong>y</strong> – a number if <em>x</em> is a number, else <code class="docutils literal notranslate"><span class="pre">None</span></code></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Return the distance from the turtle to (x,y), the given vector, or the given
other turtle, in turtle step units.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">distance</span><span class="p">(</span><span class="mi">30</span><span class="p">,</span><span class="mi">40</span><span class="p">)</span>
<span class="go">50.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">distance</span><span class="p">((</span><span class="mi">30</span><span class="p">,</span><span class="mi">40</span><span class="p">))</span>
<span class="go">50.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">joe</span> <span class="o">=</span> <span class="n">Turtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">joe</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="mi">77</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">distance</span><span class="p">(</span><span class="n">joe</span><span class="p">)</span>
<span class="go">77.0</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="settings-for-measurement">
<h3>Settings for measurement<a class="headerlink" href="#settings-for-measurement" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.degrees">
<code class="descclassname">turtle.</code><code class="descname">degrees</code><span class="sig-paren">(</span><em>fullcircle=360.0</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.degrees" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>fullcircle</strong> – a number</td>
</tr>
</tbody>
</table>
<p>Set angle measurement units, i.e. set number of “degrees” for a full circle.
Default value is 360 degrees.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">90</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">90.0</span>

<span class="go">Change angle measurement unit to grad (also known as gon,</span>
<span class="go">grade, or gradian and equals 1/100-th of the right angle.)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">degrees</span><span class="p">(</span><span class="mf">400.0</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">100.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">degrees</span><span class="p">(</span><span class="mi">360</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">90.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.radians">
<code class="descclassname">turtle.</code><code class="descname">radians</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.radians" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the angle measurement units to radians.  Equivalent to
<code class="docutils literal notranslate"><span class="pre">degrees(2*math.pi)</span></code>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">90</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">90.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">radians</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">1.5707963267948966</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="pen-control">
<h3>Pen control<a class="headerlink" href="#pen-control" title="Permalink to this headline">¶</a></h3>
<div class="section" id="drawing-state">
<h4>Drawing state<a class="headerlink" href="#drawing-state" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.pendown">
<code class="descclassname">turtle.</code><code class="descname">pendown</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.pendown" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.pd">
<code class="descclassname">turtle.</code><code class="descname">pd</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.pd" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.down">
<code class="descclassname">turtle.</code><code class="descname">down</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.down" title="Permalink to this definition">¶</a></dt>
<dd><p>Pull the pen down – drawing when moving.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.penup">
<code class="descclassname">turtle.</code><code class="descname">penup</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.penup" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.pu">
<code class="descclassname">turtle.</code><code class="descname">pu</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.pu" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.up">
<code class="descclassname">turtle.</code><code class="descname">up</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.up" title="Permalink to this definition">¶</a></dt>
<dd><p>Pull the pen up – no drawing when moving.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.pensize">
<code class="descclassname">turtle.</code><code class="descname">pensize</code><span class="sig-paren">(</span><em>width=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.pensize" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.width">
<code class="descclassname">turtle.</code><code class="descname">width</code><span class="sig-paren">(</span><em>width=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.width" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>width</strong> – a positive number</td>
</tr>
</tbody>
</table>
<p>Set the line thickness to <em>width</em> or return it.  If resizemode is set to
“auto” and turtleshape is a polygon, that polygon is drawn with the same line
thickness.  If no argument is given, the current pensize is returned.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pensize</span><span class="p">()</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pensize</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>   <span class="c1"># from here on lines of width 10 are drawn</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.pen">
<code class="descclassname">turtle.</code><code class="descname">pen</code><span class="sig-paren">(</span><em>pen=None</em>, <em>**pendict</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.pen" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>pen</strong> – a dictionary with some or all of the below listed keys</li>
<li><strong>pendict</strong> – one or more keyword-arguments with the below listed keys as keywords</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Return or set the pen’s attributes in a “pen-dictionary” with the following
key/value pairs:</p>
<ul class="simple">
<li>“shown”: True/False</li>
<li>“pendown”: True/False</li>
<li>“pencolor”: color-string or color-tuple</li>
<li>“fillcolor”: color-string or color-tuple</li>
<li>“pensize”: positive number</li>
<li>“speed”: number in range 0..10</li>
<li>“resizemode”: “auto” or “user” or “noresize”</li>
<li>“stretchfactor”: (positive number, positive number)</li>
<li>“outline”: positive number</li>
<li>“tilt”: number</li>
</ul>
<p>This dictionary can be used as argument for a subsequent call to <a class="reference internal" href="#turtle.pen" title="turtle.pen"><code class="xref py py-func docutils literal notranslate"><span class="pre">pen()</span></code></a>
to restore the former pen-state.  Moreover one or more of these attributes
can be provided as keyword-arguments.  This can be used to set several pen
attributes in one statement.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pen</span><span class="p">(</span><span class="n">fillcolor</span><span class="o">=</span><span class="s2">&quot;black&quot;</span><span class="p">,</span> <span class="n">pencolor</span><span class="o">=</span><span class="s2">&quot;red&quot;</span><span class="p">,</span> <span class="n">pensize</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">pen</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">())</span>
<span class="go">[(&#39;fillcolor&#39;, &#39;black&#39;), (&#39;outline&#39;, 1), (&#39;pencolor&#39;, &#39;red&#39;),</span>
<span class="go"> (&#39;pendown&#39;, True), (&#39;pensize&#39;, 10), (&#39;resizemode&#39;, &#39;noresize&#39;),</span>
<span class="go"> (&#39;shearfactor&#39;, 0.0), (&#39;shown&#39;, True), (&#39;speed&#39;, 9),</span>
<span class="go"> (&#39;stretchfactor&#39;, (1.0, 1.0)), (&#39;tilt&#39;, 0.0)]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">penstate</span><span class="o">=</span><span class="n">turtle</span><span class="o">.</span><span class="n">pen</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s2">&quot;yellow&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">penup</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">pen</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">())[:</span><span class="mi">3</span><span class="p">]</span>
<span class="go">[(&#39;fillcolor&#39;, &#39;&#39;), (&#39;outline&#39;, 1), (&#39;pencolor&#39;, &#39;yellow&#39;)]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pen</span><span class="p">(</span><span class="n">penstate</span><span class="p">,</span> <span class="n">fillcolor</span><span class="o">=</span><span class="s2">&quot;green&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">pen</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">())[:</span><span class="mi">3</span><span class="p">]</span>
<span class="go">[(&#39;fillcolor&#39;, &#39;green&#39;), (&#39;outline&#39;, 1), (&#39;pencolor&#39;, &#39;red&#39;)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.isdown">
<code class="descclassname">turtle.</code><code class="descname">isdown</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.isdown" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if pen is down, <code class="docutils literal notranslate"><span class="pre">False</span></code> if it’s up.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">penup</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">isdown</span><span class="p">()</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pendown</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">isdown</span><span class="p">()</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="color-control">
<h4>Color control<a class="headerlink" href="#color-control" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.pencolor">
<code class="descclassname">turtle.</code><code class="descname">pencolor</code><span class="sig-paren">(</span><em>*args</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.pencolor" title="Permalink to this definition">¶</a></dt>
<dd><p>Return or set the pencolor.</p>
<p>Four input formats are allowed:</p>
<dl class="docutils">
<dt><code class="docutils literal notranslate"><span class="pre">pencolor()</span></code></dt>
<dd>Return the current pencolor as color specification string or
as a tuple (see example).  May be used as input to another
color/pencolor/fillcolor call.</dd>
<dt><code class="docutils literal notranslate"><span class="pre">pencolor(colorstring)</span></code></dt>
<dd>Set pencolor to <em>colorstring</em>, which is a Tk color specification string,
such as <code class="docutils literal notranslate"><span class="pre">&quot;red&quot;</span></code>, <code class="docutils literal notranslate"><span class="pre">&quot;yellow&quot;</span></code>, or <code class="docutils literal notranslate"><span class="pre">&quot;#33cc8c&quot;</span></code>.</dd>
<dt><code class="docutils literal notranslate"><span class="pre">pencolor((r,</span> <span class="pre">g,</span> <span class="pre">b))</span></code></dt>
<dd>Set pencolor to the RGB color represented by the tuple of <em>r</em>, <em>g</em>, and
<em>b</em>.  Each of <em>r</em>, <em>g</em>, and <em>b</em> must be in the range 0..colormode, where
colormode is either 1.0 or 255 (see <a class="reference internal" href="#turtle.colormode" title="turtle.colormode"><code class="xref py py-func docutils literal notranslate"><span class="pre">colormode()</span></code></a>).</dd>
<dt><code class="docutils literal notranslate"><span class="pre">pencolor(r,</span> <span class="pre">g,</span> <span class="pre">b)</span></code></dt>
<dd><blockquote class="first">
<div>Set pencolor to the RGB color represented by <em>r</em>, <em>g</em>, and <em>b</em>.  Each of
<em>r</em>, <em>g</em>, and <em>b</em> must be in the range 0..colormode.</div></blockquote>
<p class="last">If turtleshape is a polygon, the outline of that polygon is drawn with the
newly set pencolor.</p>
</dd>
</dl>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">colormode</span><span class="p">()</span>
<span class="go">1.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">()</span>
<span class="go">&#39;red&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">(</span><span class="s2">&quot;brown&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">()</span>
<span class="go">&#39;brown&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">tup</span> <span class="o">=</span> <span class="p">(</span><span class="mf">0.2</span><span class="p">,</span> <span class="mf">0.8</span><span class="p">,</span> <span class="mf">0.55</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">(</span><span class="n">tup</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">()</span>
<span class="go">(0.2, 0.8, 0.5490196078431373)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">colormode</span><span class="p">(</span><span class="mi">255</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">()</span>
<span class="go">(51.0, 204.0, 140.0)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">(</span><span class="s1">&#39;#32c18f&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">()</span>
<span class="go">(50.0, 193.0, 143.0)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.fillcolor">
<code class="descclassname">turtle.</code><code class="descname">fillcolor</code><span class="sig-paren">(</span><em>*args</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.fillcolor" title="Permalink to this definition">¶</a></dt>
<dd><p>Return or set the fillcolor.</p>
<p>Four input formats are allowed:</p>
<dl class="docutils">
<dt><code class="docutils literal notranslate"><span class="pre">fillcolor()</span></code></dt>
<dd>Return the current fillcolor as color specification string, possibly
in tuple format (see example).  May be used as input to another
color/pencolor/fillcolor call.</dd>
<dt><code class="docutils literal notranslate"><span class="pre">fillcolor(colorstring)</span></code></dt>
<dd>Set fillcolor to <em>colorstring</em>, which is a Tk color specification string,
such as <code class="docutils literal notranslate"><span class="pre">&quot;red&quot;</span></code>, <code class="docutils literal notranslate"><span class="pre">&quot;yellow&quot;</span></code>, or <code class="docutils literal notranslate"><span class="pre">&quot;#33cc8c&quot;</span></code>.</dd>
<dt><code class="docutils literal notranslate"><span class="pre">fillcolor((r,</span> <span class="pre">g,</span> <span class="pre">b))</span></code></dt>
<dd>Set fillcolor to the RGB color represented by the tuple of <em>r</em>, <em>g</em>, and
<em>b</em>.  Each of <em>r</em>, <em>g</em>, and <em>b</em> must be in the range 0..colormode, where
colormode is either 1.0 or 255 (see <a class="reference internal" href="#turtle.colormode" title="turtle.colormode"><code class="xref py py-func docutils literal notranslate"><span class="pre">colormode()</span></code></a>).</dd>
<dt><code class="docutils literal notranslate"><span class="pre">fillcolor(r,</span> <span class="pre">g,</span> <span class="pre">b)</span></code></dt>
<dd><blockquote class="first">
<div>Set fillcolor to the RGB color represented by <em>r</em>, <em>g</em>, and <em>b</em>.  Each of
<em>r</em>, <em>g</em>, and <em>b</em> must be in the range 0..colormode.</div></blockquote>
<p class="last">If turtleshape is a polygon, the interior of that polygon is drawn
with the newly set fillcolor.</p>
</dd>
</dl>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">(</span><span class="s2">&quot;violet&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">()</span>
<span class="go">&#39;violet&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">()</span>
<span class="go">(50.0, 193.0, 143.0)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">((</span><span class="mi">50</span><span class="p">,</span> <span class="mi">193</span><span class="p">,</span> <span class="mi">143</span><span class="p">))</span>  <span class="c1"># Integers, not floats</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">()</span>
<span class="go">(50.0, 193.0, 143.0)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">(</span><span class="s1">&#39;#ffffff&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">()</span>
<span class="go">(255.0, 255.0, 255.0)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.color">
<code class="descclassname">turtle.</code><code class="descname">color</code><span class="sig-paren">(</span><em>*args</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.color" title="Permalink to this definition">¶</a></dt>
<dd><p>Return or set pencolor and fillcolor.</p>
<p>Several input formats are allowed.  They use 0 to 3 arguments as
follows:</p>
<dl class="docutils">
<dt><code class="docutils literal notranslate"><span class="pre">color()</span></code></dt>
<dd>Return the current pencolor and the current fillcolor as a pair of color
specification strings or tuples as returned by <a class="reference internal" href="#turtle.pencolor" title="turtle.pencolor"><code class="xref py py-func docutils literal notranslate"><span class="pre">pencolor()</span></code></a> and
<a class="reference internal" href="#turtle.fillcolor" title="turtle.fillcolor"><code class="xref py py-func docutils literal notranslate"><span class="pre">fillcolor()</span></code></a>.</dd>
<dt><code class="docutils literal notranslate"><span class="pre">color(colorstring)</span></code>, <code class="docutils literal notranslate"><span class="pre">color((r,g,b))</span></code>, <code class="docutils literal notranslate"><span class="pre">color(r,g,b)</span></code></dt>
<dd>Inputs as in <a class="reference internal" href="#turtle.pencolor" title="turtle.pencolor"><code class="xref py py-func docutils literal notranslate"><span class="pre">pencolor()</span></code></a>, set both, fillcolor and pencolor, to the
given value.</dd>
<dt><code class="docutils literal notranslate"><span class="pre">color(colorstring1,</span> <span class="pre">colorstring2)</span></code>, <code class="docutils literal notranslate"><span class="pre">color((r1,g1,b1),</span> <span class="pre">(r2,g2,b2))</span></code></dt>
<dd><blockquote class="first">
<div>Equivalent to <code class="docutils literal notranslate"><span class="pre">pencolor(colorstring1)</span></code> and <code class="docutils literal notranslate"><span class="pre">fillcolor(colorstring2)</span></code>
and analogously if the other input format is used.</div></blockquote>
<p class="last">If turtleshape is a polygon, outline and interior of that polygon is drawn
with the newly set colors.</p>
</dd>
</dl>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s2">&quot;red&quot;</span><span class="p">,</span> <span class="s2">&quot;green&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">()</span>
<span class="go">(&#39;red&#39;, &#39;green&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">color</span><span class="p">(</span><span class="s2">&quot;#285078&quot;</span><span class="p">,</span> <span class="s2">&quot;#a0c8f0&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">color</span><span class="p">()</span>
<span class="go">((40.0, 80.0, 120.0), (160.0, 200.0, 240.0))</span>
</pre></div>
</div>
</dd></dl>

<p>See also: Screen method <a class="reference internal" href="#turtle.colormode" title="turtle.colormode"><code class="xref py py-func docutils literal notranslate"><span class="pre">colormode()</span></code></a>.</p>
</div>
<div class="section" id="filling">
<h4>Filling<a class="headerlink" href="#filling" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.filling">
<code class="descclassname">turtle.</code><code class="descname">filling</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.filling" title="Permalink to this definition">¶</a></dt>
<dd><p>Return fillstate (<code class="docutils literal notranslate"><span class="pre">True</span></code> if filling, <code class="docutils literal notranslate"><span class="pre">False</span></code> else).</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">begin_fill</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">if</span> <span class="n">turtle</span><span class="o">.</span><span class="n">filling</span><span class="p">():</span>
<span class="gp">... </span>   <span class="n">turtle</span><span class="o">.</span><span class="n">pensize</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
<span class="gp">... </span><span class="k">else</span><span class="p">:</span>
<span class="gp">... </span>   <span class="n">turtle</span><span class="o">.</span><span class="n">pensize</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.begin_fill">
<code class="descclassname">turtle.</code><code class="descname">begin_fill</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.begin_fill" title="Permalink to this definition">¶</a></dt>
<dd><p>To be called just before drawing a shape to be filled.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.end_fill">
<code class="descclassname">turtle.</code><code class="descname">end_fill</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.end_fill" title="Permalink to this definition">¶</a></dt>
<dd><p>Fill the shape drawn after the last call to <a class="reference internal" href="#turtle.begin_fill" title="turtle.begin_fill"><code class="xref py py-func docutils literal notranslate"><span class="pre">begin_fill()</span></code></a>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s2">&quot;black&quot;</span><span class="p">,</span> <span class="s2">&quot;red&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">begin_fill</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">circle</span><span class="p">(</span><span class="mi">80</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">end_fill</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="more-drawing-control">
<h4>More drawing control<a class="headerlink" href="#more-drawing-control" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.reset">
<code class="descclassname">turtle.</code><code class="descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.reset" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete the turtle’s drawings from the screen, re-center the turtle and set
variables to the default values.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">goto</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="o">-</span><span class="mi">22</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,-22.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">100.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">0.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.clear">
<code class="descclassname">turtle.</code><code class="descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.clear" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete the turtle’s drawings from the screen.  Do not move turtle.  State and
position of the turtle as well as drawings of other turtles are not affected.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.write">
<code class="descclassname">turtle.</code><code class="descname">write</code><span class="sig-paren">(</span><em>arg</em>, <em>move=False</em>, <em>align=&quot;left&quot;</em>, <em>font=(&quot;Arial&quot;</em>, <em>8</em>, <em>&quot;normal&quot;)</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.write" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>arg</strong> – object to be written to the TurtleScreen</li>
<li><strong>move</strong> – True/False</li>
<li><strong>align</strong> – one of the strings “left”, “center” or right”</li>
<li><strong>font</strong> – a triple (fontname, fontsize, fonttype)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Write text - the string representation of <em>arg</em> - at the current turtle
position according to <em>align</em> (“left”, “center” or right”) and with the given
font.  If <em>move</em> is true, the pen is moved to the bottom-right corner of the
text.  By default, <em>move</em> is <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">&quot;Home = &quot;</span><span class="p">,</span> <span class="kc">True</span><span class="p">,</span> <span class="n">align</span><span class="o">=</span><span class="s2">&quot;center&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">write</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span> <span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</div>
</div>
<div class="section" id="turtle-state">
<h3>Turtle state<a class="headerlink" href="#turtle-state" title="Permalink to this headline">¶</a></h3>
<div class="section" id="visibility">
<h4>Visibility<a class="headerlink" href="#visibility" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.hideturtle">
<code class="descclassname">turtle.</code><code class="descname">hideturtle</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.hideturtle" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.ht">
<code class="descclassname">turtle.</code><code class="descname">ht</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.ht" title="Permalink to this definition">¶</a></dt>
<dd><p>Make the turtle invisible.  It’s a good idea to do this while you’re in the
middle of doing some complex drawing, because hiding the turtle speeds up the
drawing observably.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">hideturtle</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.showturtle">
<code class="descclassname">turtle.</code><code class="descname">showturtle</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.showturtle" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.st">
<code class="descclassname">turtle.</code><code class="descname">st</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.st" title="Permalink to this definition">¶</a></dt>
<dd><p>Make the turtle visible.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">showturtle</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.isvisible">
<code class="descclassname">turtle.</code><code class="descname">isvisible</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.isvisible" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the Turtle is shown, <code class="docutils literal notranslate"><span class="pre">False</span></code> if it’s hidden.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">hideturtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">isvisible</span><span class="p">()</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">showturtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">isvisible</span><span class="p">()</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="appearance">
<h4>Appearance<a class="headerlink" href="#appearance" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.shape">
<code class="descclassname">turtle.</code><code class="descname">shape</code><span class="sig-paren">(</span><em>name=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.shape" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> – a string which is a valid shapename</td>
</tr>
</tbody>
</table>
<p>Set turtle shape to shape with given <em>name</em> or, if name is not given, return
name of current shape.  Shape with <em>name</em> must exist in the TurtleScreen’s
shape dictionary.  Initially there are the following polygon shapes: “arrow”,
“turtle”, “circle”, “square”, “triangle”, “classic”.  To learn about how to
deal with shapes see Screen method <a class="reference internal" href="#turtle.register_shape" title="turtle.register_shape"><code class="xref py py-func docutils literal notranslate"><span class="pre">register_shape()</span></code></a>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">()</span>
<span class="go">&#39;classic&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="s2">&quot;turtle&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">()</span>
<span class="go">&#39;turtle&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.resizemode">
<code class="descclassname">turtle.</code><code class="descname">resizemode</code><span class="sig-paren">(</span><em>rmode=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.resizemode" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>rmode</strong> – one of the strings “auto”, “user”, “noresize”</td>
</tr>
</tbody>
</table>
<p>Set resizemode to one of the values: “auto”, “user”, “noresize”.  If <em>rmode</em>
is not given, return current resizemode.  Different resizemodes have the
following effects:</p>
<ul class="simple">
<li>“auto”: adapts the appearance of the turtle corresponding to the value of pensize.</li>
<li>“user”: adapts the appearance of the turtle according to the values of
stretchfactor and outlinewidth (outline), which are set by
<a class="reference internal" href="#turtle.shapesize" title="turtle.shapesize"><code class="xref py py-func docutils literal notranslate"><span class="pre">shapesize()</span></code></a>.</li>
<li>“noresize”: no adaption of the turtle’s appearance takes place.</li>
</ul>
<p>resizemode(“user”) is called by <a class="reference internal" href="#turtle.shapesize" title="turtle.shapesize"><code class="xref py py-func docutils literal notranslate"><span class="pre">shapesize()</span></code></a> when used with arguments.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">resizemode</span><span class="p">()</span>
<span class="go">&#39;noresize&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">resizemode</span><span class="p">(</span><span class="s2">&quot;auto&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">resizemode</span><span class="p">()</span>
<span class="go">&#39;auto&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.shapesize">
<code class="descclassname">turtle.</code><code class="descname">shapesize</code><span class="sig-paren">(</span><em>stretch_wid=None</em>, <em>stretch_len=None</em>, <em>outline=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.shapesize" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.turtlesize">
<code class="descclassname">turtle.</code><code class="descname">turtlesize</code><span class="sig-paren">(</span><em>stretch_wid=None</em>, <em>stretch_len=None</em>, <em>outline=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.turtlesize" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>stretch_wid</strong> – positive number</li>
<li><strong>stretch_len</strong> – positive number</li>
<li><strong>outline</strong> – positive number</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Return or set the pen’s attributes x/y-stretchfactors and/or outline.  Set
resizemode to “user”.  If and only if resizemode is set to “user”, the turtle
will be displayed stretched according to its stretchfactors: <em>stretch_wid</em> is
stretchfactor perpendicular to its orientation, <em>stretch_len</em> is
stretchfactor in direction of its orientation, <em>outline</em> determines the width
of the shapes’s outline.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">()</span>
<span class="go">(1.0, 1.0, 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">resizemode</span><span class="p">(</span><span class="s2">&quot;user&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">12</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">()</span>
<span class="go">(5, 5, 12)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="n">outline</span><span class="o">=</span><span class="mi">8</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">()</span>
<span class="go">(5, 5, 8)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.shearfactor">
<code class="descclassname">turtle.</code><code class="descname">shearfactor</code><span class="sig-paren">(</span><em>shear=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.shearfactor" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>shear</strong> – number (optional)</td>
</tr>
</tbody>
</table>
<p>Set or return the current shearfactor. Shear the turtleshape according to
the given shearfactor shear, which is the tangent of the shear angle.
Do <em>not</em> change the turtle’s heading (direction of movement).
If shear is not given: return the current shearfactor, i. e. the
tangent of the shear angle, by which lines parallel to the
heading of the turtle are sheared.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="s2">&quot;circle&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shearfactor</span><span class="p">(</span><span class="mf">0.5</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shearfactor</span><span class="p">()</span>
<span class="go">0.5</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.tilt">
<code class="descclassname">turtle.</code><code class="descname">tilt</code><span class="sig-paren">(</span><em>angle</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.tilt" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>angle</strong> – a number</td>
</tr>
</tbody>
</table>
<p>Rotate the turtleshape by <em>angle</em> from its current tilt-angle, but do <em>not</em>
change the turtle’s heading (direction of movement).</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="s2">&quot;circle&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">tilt</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">tilt</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.settiltangle">
<code class="descclassname">turtle.</code><code class="descname">settiltangle</code><span class="sig-paren">(</span><em>angle</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.settiltangle" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>angle</strong> – a number</td>
</tr>
</tbody>
</table>
<p>Rotate the turtleshape to point in the direction specified by <em>angle</em>,
regardless of its current tilt-angle.  <em>Do not</em> change the turtle’s heading
(direction of movement).</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="s2">&quot;circle&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">settiltangle</span><span class="p">(</span><span class="mi">45</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">settiltangle</span><span class="p">(</span><span class="o">-</span><span class="mi">45</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
</pre></div>
</div>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.1.</span></p>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.tiltangle">
<code class="descclassname">turtle.</code><code class="descname">tiltangle</code><span class="sig-paren">(</span><em>angle=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.tiltangle" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>angle</strong> – a number (optional)</td>
</tr>
</tbody>
</table>
<p>Set or return the current tilt-angle. If angle is given, rotate the
turtleshape to point in the direction specified by angle,
regardless of its current tilt-angle. Do <em>not</em> change the turtle’s
heading (direction of movement).
If angle is not given: return the current tilt-angle, i. e. the angle
between the orientation of the turtleshape and the heading of the
turtle (its direction of movement).</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="s2">&quot;circle&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">tilt</span><span class="p">(</span><span class="mi">45</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">tiltangle</span><span class="p">()</span>
<span class="go">45.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.shapetransform">
<code class="descclassname">turtle.</code><code class="descname">shapetransform</code><span class="sig-paren">(</span><em>t11=None</em>, <em>t12=None</em>, <em>t21=None</em>, <em>t22=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.shapetransform" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>t11</strong> – a number (optional)</li>
<li><strong>t12</strong> – a number (optional)</li>
<li><strong>t21</strong> – a number (optional)</li>
<li><strong>t12</strong> – a number (optional)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Set or return the current transformation matrix of the turtle shape.</p>
<p>If none of the matrix elements are given, return the transformation
matrix as a tuple of 4 elements.
Otherwise set the given elements and transform the turtleshape
according to the matrix consisting of first row t11, t12 and
second row t21, 22. The determinant t11 * t22 - t12 * t21 must not be
zero, otherwise an error is raised.
Modify stretchfactor, shearfactor and tiltangle according to the
given matrix.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span> <span class="o">=</span> <span class="n">Turtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="s2">&quot;square&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shearfactor</span><span class="p">(</span><span class="o">-</span><span class="mf">0.5</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapetransform</span><span class="p">()</span>
<span class="go">(4.0, -1.0, -0.0, 2.0)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.get_shapepoly">
<code class="descclassname">turtle.</code><code class="descname">get_shapepoly</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.get_shapepoly" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the current shape polygon as tuple of coordinate pairs. This
can be used to define a new shape or components of a compound shape.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="s2">&quot;square&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapetransform</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">get_shapepoly</span><span class="p">()</span>
<span class="go">((50, -20), (30, 20), (-50, 20), (-30, -20))</span>
</pre></div>
</div>
</dd></dl>

</div>
</div>
<div class="section" id="using-events">
<h3>Using events<a class="headerlink" href="#using-events" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.onclick">
<code class="descclassname">turtle.</code><code class="descname">onclick</code><span class="sig-paren">(</span><em>fun</em>, <em>btn=1</em>, <em>add=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.onclick" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>fun</strong> – a function with two arguments which will be called with the
coordinates of the clicked point on the canvas</li>
<li><strong>btn</strong> – number of the mouse-button, defaults to 1 (left mouse button)</li>
<li><strong>add</strong> – <code class="docutils literal notranslate"><span class="pre">True</span></code> or <code class="docutils literal notranslate"><span class="pre">False</span></code> – if <code class="docutils literal notranslate"><span class="pre">True</span></code>, a new binding will be
added, otherwise it will replace a former binding</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Bind <em>fun</em> to mouse-click events on this turtle.  If <em>fun</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>,
existing bindings are removed.  Example for the anonymous turtle, i.e. the
procedural way:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">turn</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">left</span><span class="p">(</span><span class="mi">180</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">onclick</span><span class="p">(</span><span class="n">turn</span><span class="p">)</span>  <span class="c1"># Now clicking into the turtle will turn it.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">onclick</span><span class="p">(</span><span class="bp">None</span><span class="p">)</span>  <span class="c1"># event-binding will be removed</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.onrelease">
<code class="descclassname">turtle.</code><code class="descname">onrelease</code><span class="sig-paren">(</span><em>fun</em>, <em>btn=1</em>, <em>add=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.onrelease" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>fun</strong> – a function with two arguments which will be called with the
coordinates of the clicked point on the canvas</li>
<li><strong>btn</strong> – number of the mouse-button, defaults to 1 (left mouse button)</li>
<li><strong>add</strong> – <code class="docutils literal notranslate"><span class="pre">True</span></code> or <code class="docutils literal notranslate"><span class="pre">False</span></code> – if <code class="docutils literal notranslate"><span class="pre">True</span></code>, a new binding will be
added, otherwise it will replace a former binding</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Bind <em>fun</em> to mouse-button-release events on this turtle.  If <em>fun</em> is
<code class="docutils literal notranslate"><span class="pre">None</span></code>, existing bindings are removed.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">class</span> <span class="nc">MyTurtle</span><span class="p">(</span><span class="n">Turtle</span><span class="p">):</span>
<span class="gp">... </span>    <span class="k">def</span> <span class="nf">glow</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">):</span>
<span class="gp">... </span>        <span class="bp">self</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">(</span><span class="s2">&quot;red&quot;</span><span class="p">)</span>
<span class="gp">... </span>    <span class="k">def</span> <span class="nf">unglow</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">):</span>
<span class="gp">... </span>        <span class="bp">self</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span> <span class="o">=</span> <span class="n">MyTurtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">onclick</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">glow</span><span class="p">)</span>     <span class="c1"># clicking on turtle turns fillcolor red,</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">onrelease</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">unglow</span><span class="p">)</span> <span class="c1"># releasing turns it to transparent.</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.ondrag">
<code class="descclassname">turtle.</code><code class="descname">ondrag</code><span class="sig-paren">(</span><em>fun</em>, <em>btn=1</em>, <em>add=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.ondrag" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>fun</strong> – a function with two arguments which will be called with the
coordinates of the clicked point on the canvas</li>
<li><strong>btn</strong> – number of the mouse-button, defaults to 1 (left mouse button)</li>
<li><strong>add</strong> – <code class="docutils literal notranslate"><span class="pre">True</span></code> or <code class="docutils literal notranslate"><span class="pre">False</span></code> – if <code class="docutils literal notranslate"><span class="pre">True</span></code>, a new binding will be
added, otherwise it will replace a former binding</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Bind <em>fun</em> to mouse-move events on this turtle.  If <em>fun</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>,
existing bindings are removed.</p>
<p>Remark: Every sequence of mouse-move-events on a turtle is preceded by a
mouse-click event on that turtle.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">ondrag</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">goto</span><span class="p">)</span>
</pre></div>
</div>
<p>Subsequently, clicking and dragging the Turtle will move it across
the screen thereby producing handdrawings (if pen is down).</p>
</dd></dl>

</div>
<div class="section" id="special-turtle-methods">
<h3>Special Turtle methods<a class="headerlink" href="#special-turtle-methods" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.begin_poly">
<code class="descclassname">turtle.</code><code class="descname">begin_poly</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.begin_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Start recording the vertices of a polygon.  Current turtle position is first
vertex of polygon.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.end_poly">
<code class="descclassname">turtle.</code><code class="descname">end_poly</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.end_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Stop recording the vertices of a polygon.  Current turtle position is last
vertex of polygon.  This will be connected with the first vertex.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.get_poly">
<code class="descclassname">turtle.</code><code class="descname">get_poly</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.get_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the last recorded polygon.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">begin_poly</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">20</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">60</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">end_poly</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">turtle</span><span class="o">.</span><span class="n">get_poly</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">register_shape</span><span class="p">(</span><span class="s2">&quot;myFavouriteShape&quot;</span><span class="p">,</span> <span class="n">p</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.clone">
<code class="descclassname">turtle.</code><code class="descname">clone</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.clone" title="Permalink to this definition">¶</a></dt>
<dd><p>Create and return a clone of the turtle with same position, heading and
turtle properties.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">mick</span> <span class="o">=</span> <span class="n">Turtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">joe</span> <span class="o">=</span> <span class="n">mick</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.getturtle">
<code class="descclassname">turtle.</code><code class="descname">getturtle</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.getturtle" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.getpen">
<code class="descclassname">turtle.</code><code class="descname">getpen</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.getpen" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the Turtle object itself.  Only reasonable use: as a function to
return the “anonymous turtle”:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pet</span> <span class="o">=</span> <span class="n">getturtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pet</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pet</span>
<span class="go">&lt;turtle.Turtle object at 0x...&gt;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.getscreen">
<code class="descclassname">turtle.</code><code class="descname">getscreen</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.getscreen" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the <a class="reference internal" href="#turtle.TurtleScreen" title="turtle.TurtleScreen"><code class="xref py py-class docutils literal notranslate"><span class="pre">TurtleScreen</span></code></a> object the turtle is drawing on.
TurtleScreen methods can then be called for that object.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ts</span> <span class="o">=</span> <span class="n">turtle</span><span class="o">.</span><span class="n">getscreen</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ts</span>
<span class="go">&lt;turtle._Screen object at 0x...&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ts</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">(</span><span class="s2">&quot;pink&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.setundobuffer">
<code class="descclassname">turtle.</code><code class="descname">setundobuffer</code><span class="sig-paren">(</span><em>size</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.setundobuffer" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>size</strong> – an integer or <code class="docutils literal notranslate"><span class="pre">None</span></code></td>
</tr>
</tbody>
</table>
<p>Set or disable undobuffer.  If <em>size</em> is an integer an empty undobuffer of
given size is installed.  <em>size</em> gives the maximum number of turtle actions
that can be undone by the <a class="reference internal" href="#turtle.undo" title="turtle.undo"><code class="xref py py-func docutils literal notranslate"><span class="pre">undo()</span></code></a> method/function.  If <em>size</em> is
<code class="docutils literal notranslate"><span class="pre">None</span></code>, the undobuffer is disabled.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setundobuffer</span><span class="p">(</span><span class="mi">42</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.undobufferentries">
<code class="descclassname">turtle.</code><code class="descname">undobufferentries</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.undobufferentries" title="Permalink to this definition">¶</a></dt>
<dd><p>Return number of entries in the undobuffer.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">while</span> <span class="n">undobufferentries</span><span class="p">():</span>
<span class="gp">... </span>    <span class="n">undo</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="compound-shapes">
<span id="compoundshapes"></span><h3>Compound shapes<a class="headerlink" href="#compound-shapes" title="Permalink to this headline">¶</a></h3>
<p>To use compound turtle shapes, which consist of several polygons of different
color, you must use the helper class <a class="reference internal" href="#turtle.Shape" title="turtle.Shape"><code class="xref py py-class docutils literal notranslate"><span class="pre">Shape</span></code></a> explicitly as described
below:</p>
<ol class="arabic">
<li><p class="first">Create an empty Shape object of type “compound”.</p>
</li>
<li><p class="first">Add as many components to this object as desired, using the
<code class="xref py py-meth docutils literal notranslate"><span class="pre">addcomponent()</span></code> method.</p>
<p>For example:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="n">Shape</span><span class="p">(</span><span class="s2">&quot;compound&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">poly1</span> <span class="o">=</span> <span class="p">((</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">),(</span><span class="mi">10</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">),(</span><span class="mi">0</span><span class="p">,</span><span class="mi">10</span><span class="p">),(</span><span class="o">-</span><span class="mi">10</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">addcomponent</span><span class="p">(</span><span class="n">poly1</span><span class="p">,</span> <span class="s2">&quot;red&quot;</span><span class="p">,</span> <span class="s2">&quot;blue&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">poly2</span> <span class="o">=</span> <span class="p">((</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">),(</span><span class="mi">10</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">),(</span><span class="o">-</span><span class="mi">10</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">addcomponent</span><span class="p">(</span><span class="n">poly2</span><span class="p">,</span> <span class="s2">&quot;blue&quot;</span><span class="p">,</span> <span class="s2">&quot;red&quot;</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p class="first">Now add the Shape to the Screen’s shapelist and use it:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">register_shape</span><span class="p">(</span><span class="s2">&quot;myshape&quot;</span><span class="p">,</span> <span class="n">s</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">shape</span><span class="p">(</span><span class="s2">&quot;myshape&quot;</span><span class="p">)</span>
</pre></div>
</div>
</li>
</ol>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The <a class="reference internal" href="#turtle.Shape" title="turtle.Shape"><code class="xref py py-class docutils literal notranslate"><span class="pre">Shape</span></code></a> class is used internally by the <a class="reference internal" href="#turtle.register_shape" title="turtle.register_shape"><code class="xref py py-func docutils literal notranslate"><span class="pre">register_shape()</span></code></a>
method in different ways.  The application programmer has to deal with the
Shape class <em>only</em> when using compound shapes like shown above!</p>
</div>
</div>
</div>
<div class="section" id="methods-of-turtlescreen-screen-and-corresponding-functions">
<h2>Methods of TurtleScreen/Screen and corresponding functions<a class="headerlink" href="#methods-of-turtlescreen-screen-and-corresponding-functions" title="Permalink to this headline">¶</a></h2>
<p>Most of the examples in this section refer to a TurtleScreen instance called
<code class="docutils literal notranslate"><span class="pre">screen</span></code>.</p>
<div class="section" id="window-control">
<h3>Window control<a class="headerlink" href="#window-control" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.bgcolor">
<code class="descclassname">turtle.</code><code class="descname">bgcolor</code><span class="sig-paren">(</span><em>*args</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.bgcolor" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>args</strong> – a color string or three numbers in the range 0..colormode or a
3-tuple of such numbers</td>
</tr>
</tbody>
</table>
<p>Set or return background color of the TurtleScreen.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">(</span><span class="s2">&quot;orange&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">()</span>
<span class="go">&#39;orange&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">(</span><span class="s2">&quot;#800080&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">()</span>
<span class="go">(128.0, 0.0, 128.0)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.bgpic">
<code class="descclassname">turtle.</code><code class="descname">bgpic</code><span class="sig-paren">(</span><em>picname=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.bgpic" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>picname</strong> – a string, name of a gif-file or <code class="docutils literal notranslate"><span class="pre">&quot;nopic&quot;</span></code>, or <code class="docutils literal notranslate"><span class="pre">None</span></code></td>
</tr>
</tbody>
</table>
<p>Set background image or return name of current backgroundimage.  If <em>picname</em>
is a filename, set the corresponding image as background.  If <em>picname</em> is
<code class="docutils literal notranslate"><span class="pre">&quot;nopic&quot;</span></code>, delete background image, if present.  If <em>picname</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>,
return the filename of the current backgroundimage.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgpic</span><span class="p">()</span>
<span class="go">&#39;nopic&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgpic</span><span class="p">(</span><span class="s2">&quot;landscape.gif&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgpic</span><span class="p">()</span>
<span class="go">&quot;landscape.gif&quot;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt>
<code class="descclassname">turtle.</code><code class="descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span></dt>
<dt id="turtle.clearscreen">
<code class="descclassname">turtle.</code><code class="descname">clearscreen</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.clearscreen" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete all drawings and all turtles from the TurtleScreen.  Reset the now
empty TurtleScreen to its initial state: white background, no background
image, no event bindings and tracing on.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This TurtleScreen method is available as a global function only under the
name <code class="docutils literal notranslate"><span class="pre">clearscreen</span></code>.  The global function <code class="docutils literal notranslate"><span class="pre">clear</span></code> is a different one
derived from the Turtle method <code class="docutils literal notranslate"><span class="pre">clear</span></code>.</p>
</div>
</dd></dl>

<dl class="function">
<dt>
<code class="descclassname">turtle.</code><code class="descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span></dt>
<dt id="turtle.resetscreen">
<code class="descclassname">turtle.</code><code class="descname">resetscreen</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.resetscreen" title="Permalink to this definition">¶</a></dt>
<dd><p>Reset all Turtles on the Screen to their initial state.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This TurtleScreen method is available as a global function only under the
name <code class="docutils literal notranslate"><span class="pre">resetscreen</span></code>.  The global function <code class="docutils literal notranslate"><span class="pre">reset</span></code> is another one
derived from the Turtle method <code class="docutils literal notranslate"><span class="pre">reset</span></code>.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.screensize">
<code class="descclassname">turtle.</code><code class="descname">screensize</code><span class="sig-paren">(</span><em>canvwidth=None</em>, <em>canvheight=None</em>, <em>bg=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.screensize" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>canvwidth</strong> – positive integer, new width of canvas in pixels</li>
<li><strong>canvheight</strong> – positive integer, new height of canvas in pixels</li>
<li><strong>bg</strong> – colorstring or color-tuple, new background color</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>If no arguments are given, return current (canvaswidth, canvasheight).  Else
resize the canvas the turtles are drawing on.  Do not alter the drawing
window.  To observe hidden parts of the canvas, use the scrollbars. With this
method, one can make visible those parts of a drawing which were outside the
canvas before.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">screensize</span><span class="p">()</span>
<span class="go">(400, 300)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">screensize</span><span class="p">(</span><span class="mi">2000</span><span class="p">,</span><span class="mi">1500</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">screensize</span><span class="p">()</span>
<span class="go">(2000, 1500)</span>
</pre></div>
</div>
<p>e.g. to search for an erroneously escaped turtle ;-)</p>
</dd></dl>

<dl class="function">
<dt id="turtle.setworldcoordinates">
<code class="descclassname">turtle.</code><code class="descname">setworldcoordinates</code><span class="sig-paren">(</span><em>llx</em>, <em>lly</em>, <em>urx</em>, <em>ury</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.setworldcoordinates" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>llx</strong> – a number, x-coordinate of lower left corner of canvas</li>
<li><strong>lly</strong> – a number, y-coordinate of lower left corner of canvas</li>
<li><strong>urx</strong> – a number, x-coordinate of upper right corner of canvas</li>
<li><strong>ury</strong> – a number, y-coordinate of upper right corner of canvas</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Set up user-defined coordinate system and switch to mode “world” if
necessary.  This performs a <code class="docutils literal notranslate"><span class="pre">screen.reset()</span></code>.  If mode “world” is already
active, all drawings are redrawn according to the new coordinates.</p>
<p><strong>ATTENTION</strong>: in user-defined coordinate systems angles may appear
distorted.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">setworldcoordinates</span><span class="p">(</span><span class="o">-</span><span class="mi">50</span><span class="p">,</span><span class="o">-</span><span class="mf">7.5</span><span class="p">,</span><span class="mi">50</span><span class="p">,</span><span class="mf">7.5</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">72</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">left</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">8</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">left</span><span class="p">(</span><span class="mi">45</span><span class="p">);</span> <span class="n">fd</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>   <span class="c1"># a regular octagon</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="animation-control">
<h3>Animation control<a class="headerlink" href="#animation-control" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.delay">
<code class="descclassname">turtle.</code><code class="descname">delay</code><span class="sig-paren">(</span><em>delay=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.delay" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>delay</strong> – positive integer</td>
</tr>
</tbody>
</table>
<p>Set or return the drawing <em>delay</em> in milliseconds.  (This is approximately
the time interval between two consecutive canvas updates.)  The longer the
drawing delay, the slower the animation.</p>
<p>Optional argument:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">delay</span><span class="p">()</span>
<span class="go">10</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">delay</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">delay</span><span class="p">()</span>
<span class="go">5</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.tracer">
<code class="descclassname">turtle.</code><code class="descname">tracer</code><span class="sig-paren">(</span><em>n=None</em>, <em>delay=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.tracer" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>n</strong> – nonnegative integer</li>
<li><strong>delay</strong> – nonnegative integer</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Turn turtle animation on/off and set delay for update drawings.  If
<em>n</em> is given, only each n-th regular screen update is really
performed.  (Can be used to accelerate the drawing of complex
graphics.)  When called without arguments, returns the currently
stored value of n. Second argument sets delay value (see
<a class="reference internal" href="#turtle.delay" title="turtle.delay"><code class="xref py py-func docutils literal notranslate"><span class="pre">delay()</span></code></a>).</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">tracer</span><span class="p">(</span><span class="mi">8</span><span class="p">,</span> <span class="mi">25</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dist</span> <span class="o">=</span> <span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">200</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">fd</span><span class="p">(</span><span class="n">dist</span><span class="p">)</span>
<span class="gp">... </span>    <span class="n">rt</span><span class="p">(</span><span class="mi">90</span><span class="p">)</span>
<span class="gp">... </span>    <span class="n">dist</span> <span class="o">+=</span> <span class="mi">2</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.update">
<code class="descclassname">turtle.</code><code class="descname">update</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.update" title="Permalink to this definition">¶</a></dt>
<dd><p>Perform a TurtleScreen update. To be used when tracer is turned off.</p>
</dd></dl>

<p>See also the RawTurtle/Turtle method <a class="reference internal" href="#turtle.speed" title="turtle.speed"><code class="xref py py-func docutils literal notranslate"><span class="pre">speed()</span></code></a>.</p>
</div>
<div class="section" id="using-screen-events">
<h3>Using screen events<a class="headerlink" href="#using-screen-events" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.listen">
<code class="descclassname">turtle.</code><code class="descname">listen</code><span class="sig-paren">(</span><em>xdummy=None</em>, <em>ydummy=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.listen" title="Permalink to this definition">¶</a></dt>
<dd><p>Set focus on TurtleScreen (in order to collect key-events).  Dummy arguments
are provided in order to be able to pass <a class="reference internal" href="#turtle.listen" title="turtle.listen"><code class="xref py py-func docutils literal notranslate"><span class="pre">listen()</span></code></a> to the onclick method.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.onkey">
<code class="descclassname">turtle.</code><code class="descname">onkey</code><span class="sig-paren">(</span><em>fun</em>, <em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.onkey" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.onkeyrelease">
<code class="descclassname">turtle.</code><code class="descname">onkeyrelease</code><span class="sig-paren">(</span><em>fun</em>, <em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.onkeyrelease" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>fun</strong> – a function with no arguments or <code class="docutils literal notranslate"><span class="pre">None</span></code></li>
<li><strong>key</strong> – a string: key (e.g. “a”) or key-symbol (e.g. “space”)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Bind <em>fun</em> to key-release event of key.  If <em>fun</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>, event bindings
are removed. Remark: in order to be able to register key-events, TurtleScreen
must have the focus. (See method <a class="reference internal" href="#turtle.listen" title="turtle.listen"><code class="xref py py-func docutils literal notranslate"><span class="pre">listen()</span></code></a>.)</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">f</span><span class="p">():</span>
<span class="gp">... </span>    <span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">... </span>    <span class="n">lt</span><span class="p">(</span><span class="mi">60</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">onkey</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="s2">&quot;Up&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">listen</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.onkeypress">
<code class="descclassname">turtle.</code><code class="descname">onkeypress</code><span class="sig-paren">(</span><em>fun</em>, <em>key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.onkeypress" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>fun</strong> – a function with no arguments or <code class="docutils literal notranslate"><span class="pre">None</span></code></li>
<li><strong>key</strong> – a string: key (e.g. “a”) or key-symbol (e.g. “space”)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Bind <em>fun</em> to key-press event of key if key is given,
or to any key-press-event if no key is given.
Remark: in order to be able to register key-events, TurtleScreen
must have focus. (See method <a class="reference internal" href="#turtle.listen" title="turtle.listen"><code class="xref py py-func docutils literal notranslate"><span class="pre">listen()</span></code></a>.)</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">f</span><span class="p">():</span>
<span class="gp">... </span>    <span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">onkey</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="s2">&quot;Up&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">listen</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt>
<code class="descclassname">turtle.</code><code class="descname">onclick</code><span class="sig-paren">(</span><em>fun</em>, <em>btn=1</em>, <em>add=None</em><span class="sig-paren">)</span></dt>
<dt id="turtle.onscreenclick">
<code class="descclassname">turtle.</code><code class="descname">onscreenclick</code><span class="sig-paren">(</span><em>fun</em>, <em>btn=1</em>, <em>add=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.onscreenclick" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>fun</strong> – a function with two arguments which will be called with the
coordinates of the clicked point on the canvas</li>
<li><strong>btn</strong> – number of the mouse-button, defaults to 1 (left mouse button)</li>
<li><strong>add</strong> – <code class="docutils literal notranslate"><span class="pre">True</span></code> or <code class="docutils literal notranslate"><span class="pre">False</span></code> – if <code class="docutils literal notranslate"><span class="pre">True</span></code>, a new binding will be
added, otherwise it will replace a former binding</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Bind <em>fun</em> to mouse-click events on this screen.  If <em>fun</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>,
existing bindings are removed.</p>
<p>Example for a TurtleScreen instance named <code class="docutils literal notranslate"><span class="pre">screen</span></code> and a Turtle instance
named turtle:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">onclick</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">goto</span><span class="p">)</span> <span class="c1"># Subsequently clicking into the TurtleScreen will</span>
<span class="gp">&gt;&gt;&gt; </span>                            <span class="c1"># make the turtle move to the clicked point.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">onclick</span><span class="p">(</span><span class="bp">None</span><span class="p">)</span>        <span class="c1"># remove event binding again</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This TurtleScreen method is available as a global function only under the
name <code class="docutils literal notranslate"><span class="pre">onscreenclick</span></code>.  The global function <code class="docutils literal notranslate"><span class="pre">onclick</span></code> is another one
derived from the Turtle method <code class="docutils literal notranslate"><span class="pre">onclick</span></code>.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.ontimer">
<code class="descclassname">turtle.</code><code class="descname">ontimer</code><span class="sig-paren">(</span><em>fun</em>, <em>t=0</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.ontimer" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>fun</strong> – a function with no arguments</li>
<li><strong>t</strong> – a number &gt;= 0</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Install a timer that calls <em>fun</em> after <em>t</em> milliseconds.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">running</span> <span class="o">=</span> <span class="bp">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">f</span><span class="p">():</span>
<span class="gp">... </span>    <span class="k">if</span> <span class="n">running</span><span class="p">:</span>
<span class="gp">... </span>        <span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">... </span>        <span class="n">lt</span><span class="p">(</span><span class="mi">60</span><span class="p">)</span>
<span class="gp">... </span>        <span class="n">screen</span><span class="o">.</span><span class="n">ontimer</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">250</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="p">()</span>   <span class="c1">### makes the turtle march around</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">running</span> <span class="o">=</span> <span class="bp">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.mainloop">
<code class="descclassname">turtle.</code><code class="descname">mainloop</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.mainloop" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.done">
<code class="descclassname">turtle.</code><code class="descname">done</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.done" title="Permalink to this definition">¶</a></dt>
<dd><p>Starts event loop - calling Tkinter’s mainloop function.
Must be the last statement in a turtle graphics program.
Must <em>not</em> be used if a script is run from within IDLE in -n mode
(No subprocess) - for interactive use of turtle graphics.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">mainloop</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="input-methods">
<h3>Input methods<a class="headerlink" href="#input-methods" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.textinput">
<code class="descclassname">turtle.</code><code class="descname">textinput</code><span class="sig-paren">(</span><em>title</em>, <em>prompt</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.textinput" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>title</strong> – string</li>
<li><strong>prompt</strong> – string</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Pop up a dialog window for input of a string. Parameter title is
the title of the dialog window, prompt is a text mostly describing
what information to input.
Return the string input. If the dialog is canceled, return <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">textinput</span><span class="p">(</span><span class="s2">&quot;NIM&quot;</span><span class="p">,</span> <span class="s2">&quot;Name of first player:&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.numinput">
<code class="descclassname">turtle.</code><code class="descname">numinput</code><span class="sig-paren">(</span><em>title</em>, <em>prompt</em>, <em>default=None</em>, <em>minval=None</em>, <em>maxval=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.numinput" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>title</strong> – string</li>
<li><strong>prompt</strong> – string</li>
<li><strong>default</strong> – number (optional)</li>
<li><strong>minval</strong> – number (optional)</li>
<li><strong>maxval</strong> – number (optional)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Pop up a dialog window for input of a number. title is the title of the
dialog window, prompt is a text mostly describing what numerical information
to input. default: default value, minval: minimum value for input,
maxval: maximum value for input
The number input must be in the range minval .. maxval if these are
given. If not, a hint is issued and the dialog remains open for
correction.
Return the number input. If the dialog is canceled,  return <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">numinput</span><span class="p">(</span><span class="s2">&quot;Poker&quot;</span><span class="p">,</span> <span class="s2">&quot;Your stakes:&quot;</span><span class="p">,</span> <span class="mi">1000</span><span class="p">,</span> <span class="n">minval</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">maxval</span><span class="o">=</span><span class="mi">10000</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="settings-and-special-methods">
<h3>Settings and special methods<a class="headerlink" href="#settings-and-special-methods" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.mode">
<code class="descclassname">turtle.</code><code class="descname">mode</code><span class="sig-paren">(</span><em>mode=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.mode" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mode</strong> – one of the strings “standard”, “logo” or “world”</td>
</tr>
</tbody>
</table>
<p>Set turtle mode (“standard”, “logo” or “world”) and perform reset.  If mode
is not given, current mode is returned.</p>
<p>Mode “standard” is compatible with old <a class="reference internal" href="#module-turtle" title="turtle: An educational framework for simple graphics applications"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a>.  Mode “logo” is
compatible with most Logo turtle graphics.  Mode “world” uses user-defined
“world coordinates”. <strong>Attention</strong>: in this mode angles appear distorted if
<code class="docutils literal notranslate"><span class="pre">x/y</span></code> unit-ratio doesn’t equal 1.</p>
<table border="1" class="docutils">
<colgroup>
<col width="21%" />
<col width="45%" />
<col width="34%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Mode</th>
<th class="head">Initial turtle heading</th>
<th class="head">positive angles</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>“standard”</td>
<td>to the right (east)</td>
<td>counterclockwise</td>
</tr>
<tr class="row-odd"><td>“logo”</td>
<td>upward    (north)</td>
<td>clockwise</td>
</tr>
</tbody>
</table>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">mode</span><span class="p">(</span><span class="s2">&quot;logo&quot;</span><span class="p">)</span>   <span class="c1"># resets turtle heading to north</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mode</span><span class="p">()</span>
<span class="go">&#39;logo&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.colormode">
<code class="descclassname">turtle.</code><code class="descname">colormode</code><span class="sig-paren">(</span><em>cmode=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.colormode" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>cmode</strong> – one of the values 1.0 or 255</td>
</tr>
</tbody>
</table>
<p>Return the colormode or set it to 1.0 or 255.  Subsequently <em>r</em>, <em>g</em>, <em>b</em>
values of color triples have to be in the range 0..<em>cmode</em>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">colormode</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">(</span><span class="mi">240</span><span class="p">,</span> <span class="mi">160</span><span class="p">,</span> <span class="mi">80</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
     <span class="o">...</span>
<span class="gr">TurtleGraphicsError</span>: <span class="n">bad color sequence: (240, 160, 80)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">colormode</span><span class="p">()</span>
<span class="go">1.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">colormode</span><span class="p">(</span><span class="mi">255</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">colormode</span><span class="p">()</span>
<span class="go">255</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">(</span><span class="mi">240</span><span class="p">,</span><span class="mi">160</span><span class="p">,</span><span class="mi">80</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.getcanvas">
<code class="descclassname">turtle.</code><code class="descname">getcanvas</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.getcanvas" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the Canvas of this TurtleScreen.  Useful for insiders who know what to
do with a Tkinter Canvas.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">cv</span> <span class="o">=</span> <span class="n">screen</span><span class="o">.</span><span class="n">getcanvas</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cv</span>
<span class="go">&lt;turtle.ScrolledCanvas object ...&gt;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.getshapes">
<code class="descclassname">turtle.</code><code class="descname">getshapes</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.getshapes" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of names of all currently available turtle shapes.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">getshapes</span><span class="p">()</span>
<span class="go">[&#39;arrow&#39;, &#39;blank&#39;, &#39;circle&#39;, ..., &#39;turtle&#39;]</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.register_shape">
<code class="descclassname">turtle.</code><code class="descname">register_shape</code><span class="sig-paren">(</span><em>name</em>, <em>shape=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.register_shape" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.addshape">
<code class="descclassname">turtle.</code><code class="descname">addshape</code><span class="sig-paren">(</span><em>name</em>, <em>shape=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.addshape" title="Permalink to this definition">¶</a></dt>
<dd><p>There are three different ways to call this function:</p>
<ol class="arabic">
<li><p class="first"><em>name</em> is the name of a gif-file and <em>shape</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>: Install the
corresponding image shape.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">register_shape</span><span class="p">(</span><span class="s2">&quot;turtle.gif&quot;</span><span class="p">)</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Image shapes <em>do not</em> rotate when turning the turtle, so they do not
display the heading of the turtle!</p>
</div>
</li>
<li><p class="first"><em>name</em> is an arbitrary string and <em>shape</em> is a tuple of pairs of
coordinates: Install the corresponding polygon shape.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">register_shape</span><span class="p">(</span><span class="s2">&quot;triangle&quot;</span><span class="p">,</span> <span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="o">-</span><span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span> <span class="p">(</span><span class="o">-</span><span class="mi">5</span><span class="p">,</span><span class="o">-</span><span class="mi">3</span><span class="p">)))</span>
</pre></div>
</div>
</li>
<li><p class="first"><em>name</em> is an arbitrary string and shape is a (compound) <a class="reference internal" href="#turtle.Shape" title="turtle.Shape"><code class="xref py py-class docutils literal notranslate"><span class="pre">Shape</span></code></a>
object: Install the corresponding compound shape.</p>
</li>
</ol>
<p>Add a turtle shape to TurtleScreen’s shapelist.  Only thusly registered
shapes can be used by issuing the command <code class="docutils literal notranslate"><span class="pre">shape(shapename)</span></code>.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.turtles">
<code class="descclassname">turtle.</code><code class="descname">turtles</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.turtles" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the list of turtles on the screen.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">turtle</span> <span class="ow">in</span> <span class="n">screen</span><span class="o">.</span><span class="n">turtles</span><span class="p">():</span>
<span class="gp">... </span>    <span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s2">&quot;red&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.window_height">
<code class="descclassname">turtle.</code><code class="descname">window_height</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.window_height" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the height of the turtle window.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">window_height</span><span class="p">()</span>
<span class="go">480</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.window_width">
<code class="descclassname">turtle.</code><code class="descname">window_width</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.window_width" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the width of the turtle window.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">window_width</span><span class="p">()</span>
<span class="go">640</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="methods-specific-to-screen-not-inherited-from-turtlescreen">
<span id="screenspecific"></span><h3>Methods specific to Screen, not inherited from TurtleScreen<a class="headerlink" href="#methods-specific-to-screen-not-inherited-from-turtlescreen" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.bye">
<code class="descclassname">turtle.</code><code class="descname">bye</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.bye" title="Permalink to this definition">¶</a></dt>
<dd><p>Shut the turtlegraphics window.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.exitonclick">
<code class="descclassname">turtle.</code><code class="descname">exitonclick</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.exitonclick" title="Permalink to this definition">¶</a></dt>
<dd><p>Bind bye() method to mouse clicks on the Screen.</p>
<p>If the value “using_IDLE” in the configuration dictionary is <code class="docutils literal notranslate"><span class="pre">False</span></code>
(default value), also enter mainloop.  Remark: If IDLE with the <code class="docutils literal notranslate"><span class="pre">-n</span></code> switch
(no subprocess) is used, this value should be set to <code class="docutils literal notranslate"><span class="pre">True</span></code> in
<code class="file docutils literal notranslate"><span class="pre">turtle.cfg</span></code>.  In this case IDLE’s own mainloop is active also for the
client script.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.setup">
<code class="descclassname">turtle.</code><code class="descname">setup</code><span class="sig-paren">(</span><em>width=_CFG[&quot;width&quot;], height=_CFG[&quot;height&quot;], startx=_CFG[&quot;leftright&quot;], starty=_CFG[&quot;topbottom&quot;]</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.setup" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the size and position of the main window.  Default values of arguments
are stored in the configuration dictionary and can be changed via a
<code class="file docutils literal notranslate"><span class="pre">turtle.cfg</span></code> file.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>width</strong> – if an integer, a size in pixels, if a float, a fraction of the
screen; default is 50% of screen</li>
<li><strong>height</strong> – if an integer, the height in pixels, if a float, a fraction of
the screen; default is 75% of screen</li>
<li><strong>startx</strong> – if positive, starting position in pixels from the left
edge of the screen, if negative from the right edge, if <code class="docutils literal notranslate"><span class="pre">None</span></code>,
center window horizontally</li>
<li><strong>starty</strong> – if positive, starting position in pixels from the top
edge of the screen, if negative from the bottom edge, if <code class="docutils literal notranslate"><span class="pre">None</span></code>,
center window vertically</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">setup</span> <span class="p">(</span><span class="n">width</span><span class="o">=</span><span class="mi">200</span><span class="p">,</span> <span class="n">height</span><span class="o">=</span><span class="mi">200</span><span class="p">,</span> <span class="n">startx</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">starty</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span>             <span class="c1"># sets window to 200x200 pixels, in upper left of screen</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">setup</span><span class="p">(</span><span class="n">width</span><span class="o">=.</span><span class="mi">75</span><span class="p">,</span> <span class="n">height</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="n">startx</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">starty</span><span class="o">=</span><span class="bp">None</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span>             <span class="c1"># sets window to 75% of screen by 50% of screen and centers</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.title">
<code class="descclassname">turtle.</code><code class="descname">title</code><span class="sig-paren">(</span><em>titlestring</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.title" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>titlestring</strong> – a string that is shown in the titlebar of the turtle
graphics window</td>
</tr>
</tbody>
</table>
<p>Set title of turtle window to <em>titlestring</em>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="s2">&quot;Welcome to the turtle zoo!&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</div>
</div>
<div class="section" id="public-classes">
<h2>Public classes<a class="headerlink" href="#public-classes" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="turtle.RawTurtle">
<em class="property">class </em><code class="descclassname">turtle.</code><code class="descname">RawTurtle</code><span class="sig-paren">(</span><em>canvas</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.RawTurtle" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.RawPen">
<em class="property">class </em><code class="descclassname">turtle.</code><code class="descname">RawPen</code><span class="sig-paren">(</span><em>canvas</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.RawPen" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>canvas</strong> – a <code class="xref py py-class docutils literal notranslate"><span class="pre">tkinter.Canvas</span></code>, a <a class="reference internal" href="#turtle.ScrolledCanvas" title="turtle.ScrolledCanvas"><code class="xref py py-class docutils literal notranslate"><span class="pre">ScrolledCanvas</span></code></a> or a
<a class="reference internal" href="#turtle.TurtleScreen" title="turtle.TurtleScreen"><code class="xref py py-class docutils literal notranslate"><span class="pre">TurtleScreen</span></code></a></td>
</tr>
</tbody>
</table>
<p>Create a turtle.  The turtle has all methods described above as “methods of
Turtle/RawTurtle”.</p>
</dd></dl>

<dl class="class">
<dt id="turtle.Turtle">
<em class="property">class </em><code class="descclassname">turtle.</code><code class="descname">Turtle</code><a class="headerlink" href="#turtle.Turtle" title="Permalink to this definition">¶</a></dt>
<dd><p>Subclass of RawTurtle, has the same interface but draws on a default
<a class="reference internal" href="#turtle.Screen" title="turtle.Screen"><code class="xref py py-class docutils literal notranslate"><span class="pre">Screen</span></code></a> object created automatically when needed for the first time.</p>
</dd></dl>

<dl class="class">
<dt id="turtle.TurtleScreen">
<em class="property">class </em><code class="descclassname">turtle.</code><code class="descname">TurtleScreen</code><span class="sig-paren">(</span><em>cv</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.TurtleScreen" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>cv</strong> – a <code class="xref py py-class docutils literal notranslate"><span class="pre">tkinter.Canvas</span></code></td>
</tr>
</tbody>
</table>
<p>Provides screen oriented methods like <code class="xref py py-func docutils literal notranslate"><span class="pre">setbg()</span></code> etc. that are described
above.</p>
</dd></dl>

<dl class="class">
<dt id="turtle.Screen">
<em class="property">class </em><code class="descclassname">turtle.</code><code class="descname">Screen</code><a class="headerlink" href="#turtle.Screen" title="Permalink to this definition">¶</a></dt>
<dd><p>Subclass of TurtleScreen, with <a class="reference internal" href="#screenspecific"><span class="std std-ref">four methods added</span></a>.</p>
</dd></dl>

<dl class="class">
<dt id="turtle.ScrolledCanvas">
<em class="property">class </em><code class="descclassname">turtle.</code><code class="descname">ScrolledCanvas</code><span class="sig-paren">(</span><em>master</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.ScrolledCanvas" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>master</strong> – some Tkinter widget to contain the ScrolledCanvas, i.e.
a Tkinter-canvas with scrollbars added</td>
</tr>
</tbody>
</table>
<p>Used by class Screen, which thus automatically provides a ScrolledCanvas as
playground for the turtles.</p>
</dd></dl>

<dl class="class">
<dt id="turtle.Shape">
<em class="property">class </em><code class="descclassname">turtle.</code><code class="descname">Shape</code><span class="sig-paren">(</span><em>type_</em>, <em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.Shape" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>type_</strong> – one of the strings “polygon”, “image”, “compound”</td>
</tr>
</tbody>
</table>
<p>Data structure modeling shapes.  The pair <code class="docutils literal notranslate"><span class="pre">(type_,</span> <span class="pre">data)</span></code> must follow this
specification:</p>
<table border="1" class="docutils">
<colgroup>
<col width="16%" />
<col width="84%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head"><em>type_</em></th>
<th class="head"><em>data</em></th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>“polygon”</td>
<td>a polygon-tuple, i.e. a tuple of pairs of coordinates</td>
</tr>
<tr class="row-odd"><td>“image”</td>
<td>an image  (in this form only used internally!)</td>
</tr>
<tr class="row-even"><td>“compound”</td>
<td><code class="docutils literal notranslate"><span class="pre">None</span></code> (a compound shape has to be constructed using the
<a class="reference internal" href="#turtle.Shape.addcomponent" title="turtle.Shape.addcomponent"><code class="xref py py-meth docutils literal notranslate"><span class="pre">addcomponent()</span></code></a> method)</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="turtle.Shape.addcomponent">
<code class="descname">addcomponent</code><span class="sig-paren">(</span><em>poly</em>, <em>fill</em>, <em>outline=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.Shape.addcomponent" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>poly</strong> – a polygon, i.e. a tuple of pairs of numbers</li>
<li><strong>fill</strong> – a color the <em>poly</em> will be filled with</li>
<li><strong>outline</strong> – a color for the poly’s outline (if given)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Example:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">poly</span> <span class="o">=</span> <span class="p">((</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">),(</span><span class="mi">10</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">),(</span><span class="mi">0</span><span class="p">,</span><span class="mi">10</span><span class="p">),(</span><span class="o">-</span><span class="mi">10</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="n">Shape</span><span class="p">(</span><span class="s2">&quot;compound&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">addcomponent</span><span class="p">(</span><span class="n">poly</span><span class="p">,</span> <span class="s2">&quot;red&quot;</span><span class="p">,</span> <span class="s2">&quot;blue&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># ... add more components and then use register_shape()</span>
</pre></div>
</div>
<p>See <a class="reference internal" href="#compoundshapes"><span class="std std-ref">Compound shapes</span></a>.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="turtle.Vec2D">
<em class="property">class </em><code class="descclassname">turtle.</code><code class="descname">Vec2D</code><span class="sig-paren">(</span><em>x</em>, <em>y</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.Vec2D" title="Permalink to this definition">¶</a></dt>
<dd><p>A two-dimensional vector class, used as a helper class for implementing
turtle graphics.  May be useful for turtle graphics programs too.  Derived
from tuple, so a vector is a tuple!</p>
<p>Provides (for <em>a</em>, <em>b</em> vectors, <em>k</em> number):</p>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">a</span> <span class="pre">+</span> <span class="pre">b</span></code> vector addition</li>
<li><code class="docutils literal notranslate"><span class="pre">a</span> <span class="pre">-</span> <span class="pre">b</span></code> vector subtraction</li>
<li><code class="docutils literal notranslate"><span class="pre">a</span> <span class="pre">*</span> <span class="pre">b</span></code> inner product</li>
<li><code class="docutils literal notranslate"><span class="pre">k</span> <span class="pre">*</span> <span class="pre">a</span></code> and <code class="docutils literal notranslate"><span class="pre">a</span> <span class="pre">*</span> <span class="pre">k</span></code> multiplication with scalar</li>
<li><code class="docutils literal notranslate"><span class="pre">abs(a)</span></code> absolute value of a</li>
<li><code class="docutils literal notranslate"><span class="pre">a.rotate(angle)</span></code> rotation</li>
</ul>
</dd></dl>

</div>
<div class="section" id="help-and-configuration">
<h2>Help and configuration<a class="headerlink" href="#help-and-configuration" title="Permalink to this headline">¶</a></h2>
<div class="section" id="how-to-use-help">
<h3>How to use help<a class="headerlink" href="#how-to-use-help" title="Permalink to this headline">¶</a></h3>
<p>The public methods of the Screen and Turtle classes are documented extensively
via docstrings.  So these can be used as online-help via the Python help
facilities:</p>
<ul>
<li><p class="first">When using IDLE, tooltips show the signatures and first lines of the
docstrings of typed in function-/method calls.</p>
</li>
<li><p class="first">Calling <a class="reference internal" href="functions.html#help" title="help"><code class="xref py py-func docutils literal notranslate"><span class="pre">help()</span></code></a> on methods or functions displays the docstrings:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">help</span><span class="p">(</span><span class="n">Screen</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">)</span>
<span class="go">Help on method bgcolor in module turtle:</span>

<span class="go">bgcolor(self, *args) unbound turtle.Screen method</span>
<span class="go">    Set or return backgroundcolor of the TurtleScreen.</span>

<span class="go">    Arguments (if given): a color string or three numbers</span>
<span class="go">    in the range 0..colormode or a 3-tuple of such numbers.</span>


<span class="go">      &gt;&gt;&gt; screen.bgcolor(&quot;orange&quot;)</span>
<span class="go">      &gt;&gt;&gt; screen.bgcolor()</span>
<span class="go">      &quot;orange&quot;</span>
<span class="go">      &gt;&gt;&gt; screen.bgcolor(0.5,0,0.5)</span>
<span class="go">      &gt;&gt;&gt; screen.bgcolor()</span>
<span class="go">      &quot;#800080&quot;</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">help</span><span class="p">(</span><span class="n">Turtle</span><span class="o">.</span><span class="n">penup</span><span class="p">)</span>
<span class="go">Help on method penup in module turtle:</span>

<span class="go">penup(self) unbound turtle.Turtle method</span>
<span class="go">    Pull the pen up -- no drawing when moving.</span>

<span class="go">    Aliases: penup | pu | up</span>

<span class="go">    No argument</span>

<span class="go">    &gt;&gt;&gt; turtle.penup()</span>
</pre></div>
</div>
</li>
<li><p class="first">The docstrings of the functions which are derived from methods have a modified
form:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">help</span><span class="p">(</span><span class="n">bgcolor</span><span class="p">)</span>
<span class="go">Help on function bgcolor in module turtle:</span>

<span class="go">bgcolor(*args)</span>
<span class="go">    Set or return backgroundcolor of the TurtleScreen.</span>

<span class="go">    Arguments (if given): a color string or three numbers</span>
<span class="go">    in the range 0..colormode or a 3-tuple of such numbers.</span>

<span class="go">    Example::</span>

<span class="go">      &gt;&gt;&gt; bgcolor(&quot;orange&quot;)</span>
<span class="go">      &gt;&gt;&gt; bgcolor()</span>
<span class="go">      &quot;orange&quot;</span>
<span class="go">      &gt;&gt;&gt; bgcolor(0.5,0,0.5)</span>
<span class="go">      &gt;&gt;&gt; bgcolor()</span>
<span class="go">      &quot;#800080&quot;</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">help</span><span class="p">(</span><span class="n">penup</span><span class="p">)</span>
<span class="go">Help on function penup in module turtle:</span>

<span class="go">penup()</span>
<span class="go">    Pull the pen up -- no drawing when moving.</span>

<span class="go">    Aliases: penup | pu | up</span>

<span class="go">    No argument</span>

<span class="go">    Example:</span>
<span class="go">    &gt;&gt;&gt; penup()</span>
</pre></div>
</div>
</li>
</ul>
<p>These modified docstrings are created automatically together with the function
definitions that are derived from the methods at import time.</p>
</div>
<div class="section" id="translation-of-docstrings-into-different-languages">
<h3>Translation of docstrings into different languages<a class="headerlink" href="#translation-of-docstrings-into-different-languages" title="Permalink to this headline">¶</a></h3>
<p>There is a utility to create a dictionary the keys of which are the method names
and the values of which are the docstrings of the public methods of the classes
Screen and Turtle.</p>
<dl class="function">
<dt id="turtle.write_docstringdict">
<code class="descclassname">turtle.</code><code class="descname">write_docstringdict</code><span class="sig-paren">(</span><em>filename=&quot;turtle_docstringdict&quot;</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.write_docstringdict" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>filename</strong> – a string, used as filename</td>
</tr>
</tbody>
</table>
<p>Create and write docstring-dictionary to a Python script with the given
filename.  This function has to be called explicitly (it is not used by the
turtle graphics classes).  The docstring dictionary will be written to the
Python script <code class="file docutils literal notranslate"><em><span class="pre">filename</span></em><span class="pre">.py</span></code>.  It is intended to serve as a template
for translation of the docstrings into different languages.</p>
</dd></dl>

<p>If you (or your students) want to use <a class="reference internal" href="#module-turtle" title="turtle: An educational framework for simple graphics applications"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a> with online help in your
native language, you have to translate the docstrings and save the resulting
file as e.g. <code class="file docutils literal notranslate"><span class="pre">turtle_docstringdict_german.py</span></code>.</p>
<p>If you have an appropriate entry in your <code class="file docutils literal notranslate"><span class="pre">turtle.cfg</span></code> file this dictionary
will be read in at import time and will replace the original English docstrings.</p>
<p>At the time of this writing there are docstring dictionaries in German and in
Italian.  (Requests please to <a class="reference external" href="mailto:glingl&#37;&#52;&#48;aon&#46;at">glingl<span>&#64;</span>aon<span>&#46;</span>at</a>.)</p>
</div>
<div class="section" id="how-to-configure-screen-and-turtles">
<h3>How to configure Screen and Turtles<a class="headerlink" href="#how-to-configure-screen-and-turtles" title="Permalink to this headline">¶</a></h3>
<p>The built-in default configuration mimics the appearance and behaviour of the
old turtle module in order to retain best possible compatibility with it.</p>
<p>If you want to use a different configuration which better reflects the features
of this module or which better fits to your needs, e.g. for use in a classroom,
you can prepare a configuration file <code class="docutils literal notranslate"><span class="pre">turtle.cfg</span></code> which will be read at import
time and modify the configuration according to its settings.</p>
<p>The built in configuration would correspond to the following turtle.cfg:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">width</span> <span class="o">=</span> <span class="mf">0.5</span>
<span class="n">height</span> <span class="o">=</span> <span class="mf">0.75</span>
<span class="n">leftright</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">topbottom</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">canvwidth</span> <span class="o">=</span> <span class="mi">400</span>
<span class="n">canvheight</span> <span class="o">=</span> <span class="mi">300</span>
<span class="n">mode</span> <span class="o">=</span> <span class="n">standard</span>
<span class="n">colormode</span> <span class="o">=</span> <span class="mf">1.0</span>
<span class="n">delay</span> <span class="o">=</span> <span class="mi">10</span>
<span class="n">undobuffersize</span> <span class="o">=</span> <span class="mi">1000</span>
<span class="n">shape</span> <span class="o">=</span> <span class="n">classic</span>
<span class="n">pencolor</span> <span class="o">=</span> <span class="n">black</span>
<span class="n">fillcolor</span> <span class="o">=</span> <span class="n">black</span>
<span class="n">resizemode</span> <span class="o">=</span> <span class="n">noresize</span>
<span class="n">visible</span> <span class="o">=</span> <span class="kc">True</span>
<span class="n">language</span> <span class="o">=</span> <span class="n">english</span>
<span class="n">exampleturtle</span> <span class="o">=</span> <span class="n">turtle</span>
<span class="n">examplescreen</span> <span class="o">=</span> <span class="n">screen</span>
<span class="n">title</span> <span class="o">=</span> <span class="n">Python</span> <span class="n">Turtle</span> <span class="n">Graphics</span>
<span class="n">using_IDLE</span> <span class="o">=</span> <span class="kc">False</span>
</pre></div>
</div>
<p>Short explanation of selected entries:</p>
<ul class="simple">
<li>The first four lines correspond to the arguments of the <code class="xref py py-meth docutils literal notranslate"><span class="pre">Screen.setup()</span></code>
method.</li>
<li>Line 5 and 6 correspond to the arguments of the method
<code class="xref py py-meth docutils literal notranslate"><span class="pre">Screen.screensize()</span></code>.</li>
<li><em>shape</em> can be any of the built-in shapes, e.g: arrow, turtle, etc.  For more
info try <code class="docutils literal notranslate"><span class="pre">help(shape)</span></code>.</li>
<li>If you want to use no fillcolor (i.e. make the turtle transparent), you have
to write <code class="docutils literal notranslate"><span class="pre">fillcolor</span> <span class="pre">=</span> <span class="pre">&quot;&quot;</span></code> (but all nonempty strings must not have quotes in
the cfg-file).</li>
<li>If you want to reflect the turtle its state, you have to use <code class="docutils literal notranslate"><span class="pre">resizemode</span> <span class="pre">=</span>
<span class="pre">auto</span></code>.</li>
<li>If you set e.g. <code class="docutils literal notranslate"><span class="pre">language</span> <span class="pre">=</span> <span class="pre">italian</span></code> the docstringdict
<code class="file docutils literal notranslate"><span class="pre">turtle_docstringdict_italian.py</span></code> will be loaded at import time (if
present on the import path, e.g. in the same directory as <a class="reference internal" href="#module-turtle" title="turtle: An educational framework for simple graphics applications"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a>.</li>
<li>The entries <em>exampleturtle</em> and <em>examplescreen</em> define the names of these
objects as they occur in the docstrings.  The transformation of
method-docstrings to function-docstrings will delete these names from the
docstrings.</li>
<li><em>using_IDLE</em>: Set this to <code class="docutils literal notranslate"><span class="pre">True</span></code> if you regularly work with IDLE and its -n
switch (“no subprocess”).  This will prevent <a class="reference internal" href="#turtle.exitonclick" title="turtle.exitonclick"><code class="xref py py-func docutils literal notranslate"><span class="pre">exitonclick()</span></code></a> to enter the
mainloop.</li>
</ul>
<p>There can be a <code class="file docutils literal notranslate"><span class="pre">turtle.cfg</span></code> file in the directory where <a class="reference internal" href="#module-turtle" title="turtle: An educational framework for simple graphics applications"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a> is
stored and an additional one in the current working directory.  The latter will
override the settings of the first one.</p>
<p>The <code class="file docutils literal notranslate"><span class="pre">Lib/turtledemo</span></code> directory contains a <code class="file docutils literal notranslate"><span class="pre">turtle.cfg</span></code> file.  You can
study it as an example and see its effects when running the demos (preferably
not from within the demo-viewer).</p>
</div>
</div>
<div class="section" id="module-turtledemo">
<span id="turtledemo-demo-scripts"></span><h2><a class="reference internal" href="#module-turtledemo" title="turtledemo: A viewer for example turtle scripts"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtledemo</span></code></a> — Demo scripts<a class="headerlink" href="#module-turtledemo" title="Permalink to this headline">¶</a></h2>
<p>The <a class="reference internal" href="#module-turtledemo" title="turtledemo: A viewer for example turtle scripts"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtledemo</span></code></a> package includes a set of demo scripts.  These
scripts can be run and viewed using the supplied demo viewer as follows:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="o">-</span><span class="n">m</span> <span class="n">turtledemo</span>
</pre></div>
</div>
<p>Alternatively, you can run the demo scripts individually.  For example,</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="o">-</span><span class="n">m</span> <span class="n">turtledemo</span><span class="o">.</span><span class="n">bytedesign</span>
</pre></div>
</div>
<p>The <a class="reference internal" href="#module-turtledemo" title="turtledemo: A viewer for example turtle scripts"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtledemo</span></code></a> package directory contains:</p>
<ul class="simple">
<li>A demo viewer <code class="file docutils literal notranslate"><span class="pre">__main__.py</span></code> which can be used to view the sourcecode
of the scripts and run them at the same time.</li>
<li>Multiple scripts demonstrating different features of the <a class="reference internal" href="#module-turtle" title="turtle: An educational framework for simple graphics applications"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a>
module.  Examples can be accessed via the Examples menu.  They can also
be run standalone.</li>
<li>A <code class="file docutils literal notranslate"><span class="pre">turtle.cfg</span></code> file which serves as an example of how to write
and use such files.</li>
</ul>
<p>The demo scripts are:</p>
<table border="1" class="docutils">
<colgroup>
<col width="23%" />
<col width="43%" />
<col width="33%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Name</th>
<th class="head">Description</th>
<th class="head">Features</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>bytedesign</td>
<td>complex classical
turtle graphics pattern</td>
<td><code class="xref py py-func docutils literal notranslate"><span class="pre">tracer()</span></code>, delay,
<code class="xref py py-func docutils literal notranslate"><span class="pre">update()</span></code></td>
</tr>
<tr class="row-odd"><td>chaos</td>
<td>graphs Verhulst dynamics,
shows that computer’s
computations can generate
results sometimes against the
common sense expectations</td>
<td>world coordinates</td>
</tr>
<tr class="row-even"><td>clock</td>
<td>analog clock showing time
of your computer</td>
<td>turtles as clock’s
hands, ontimer</td>
</tr>
<tr class="row-odd"><td>colormixer</td>
<td>experiment with r, g, b</td>
<td><code class="xref py py-func docutils literal notranslate"><span class="pre">ondrag()</span></code></td>
</tr>
<tr class="row-even"><td>forest</td>
<td>3 breadth-first trees</td>
<td>randomization</td>
</tr>
<tr class="row-odd"><td>fractalcurves</td>
<td>Hilbert &amp; Koch curves</td>
<td>recursion</td>
</tr>
<tr class="row-even"><td>lindenmayer</td>
<td>ethnomathematics
(indian kolams)</td>
<td>L-System</td>
</tr>
<tr class="row-odd"><td>minimal_hanoi</td>
<td>Towers of Hanoi</td>
<td>Rectangular Turtles
as Hanoi discs
(shape, shapesize)</td>
</tr>
<tr class="row-even"><td>nim</td>
<td>play the classical nim game
with three heaps of sticks
against the computer.</td>
<td>turtles as nimsticks,
event driven (mouse,
keyboard)</td>
</tr>
<tr class="row-odd"><td>paint</td>
<td>super minimalistic
drawing program</td>
<td><code class="xref py py-func docutils literal notranslate"><span class="pre">onclick()</span></code></td>
</tr>
<tr class="row-even"><td>peace</td>
<td>elementary</td>
<td>turtle: appearance
and animation</td>
</tr>
<tr class="row-odd"><td>penrose</td>
<td>aperiodic tiling with
kites and darts</td>
<td><code class="xref py py-func docutils literal notranslate"><span class="pre">stamp()</span></code></td>
</tr>
<tr class="row-even"><td>planet_and_moon</td>
<td>simulation of
gravitational system</td>
<td>compound shapes,
<code class="xref py py-class docutils literal notranslate"><span class="pre">Vec2D</span></code></td>
</tr>
<tr class="row-odd"><td>round_dance</td>
<td>dancing turtles rotating
pairwise in opposite
direction</td>
<td>compound shapes, clone
shapesize, tilt,
get_shapepoly, update</td>
</tr>
<tr class="row-even"><td>sorting_animate</td>
<td>visual demonstration of
different sorting methods</td>
<td>simple alignment,
randomization</td>
</tr>
<tr class="row-odd"><td>tree</td>
<td>a (graphical) breadth
first tree (using generators)</td>
<td><code class="xref py py-func docutils literal notranslate"><span class="pre">clone()</span></code></td>
</tr>
<tr class="row-even"><td>two_canvases</td>
<td>simple design</td>
<td>turtles on two
canvases</td>
</tr>
<tr class="row-odd"><td>wikipedia</td>
<td>a pattern from the wikipedia
article on turtle graphics</td>
<td><code class="xref py py-func docutils literal notranslate"><span class="pre">clone()</span></code>,
<code class="xref py py-func docutils literal notranslate"><span class="pre">undo()</span></code></td>
</tr>
<tr class="row-even"><td>yinyang</td>
<td>another elementary example</td>
<td><code class="xref py py-func docutils literal notranslate"><span class="pre">circle()</span></code></td>
</tr>
</tbody>
</table>
<p>Have fun!</p>
</div>
<div class="section" id="changes-since-python-2-6">
<h2>Changes since Python 2.6<a class="headerlink" href="#changes-since-python-2-6" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li>The methods <code class="xref py py-meth docutils literal notranslate"><span class="pre">Turtle.tracer()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">Turtle.window_width()</span></code> and
<code class="xref py py-meth docutils literal notranslate"><span class="pre">Turtle.window_height()</span></code> have been eliminated.
Methods with these names and functionality are now available only
as methods of <code class="xref py py-class docutils literal notranslate"><span class="pre">Screen</span></code>. The functions derived from these remain
available. (In fact already in Python 2.6 these methods were merely
duplications of the corresponding
<code class="xref py py-class docutils literal notranslate"><span class="pre">TurtleScreen</span></code>/<code class="xref py py-class docutils literal notranslate"><span class="pre">Screen</span></code>-methods.)</li>
<li>The method <code class="xref py py-meth docutils literal notranslate"><span class="pre">Turtle.fill()</span></code> has been eliminated.
The behaviour of <code class="xref py py-meth docutils literal notranslate"><span class="pre">begin_fill()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">end_fill()</span></code>
have changed slightly: now  every filling-process must be completed with an
<code class="docutils literal notranslate"><span class="pre">end_fill()</span></code> call.</li>
<li>A method <code class="xref py py-meth docutils literal notranslate"><span class="pre">Turtle.filling()</span></code> has been added. It returns a boolean
value: <code class="docutils literal notranslate"><span class="pre">True</span></code> if a filling process is under way, <code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise.
This behaviour corresponds to a <code class="docutils literal notranslate"><span class="pre">fill()</span></code> call without arguments in
Python 2.6.</li>
</ul>
</div>
<div class="section" id="changes-since-python-3-0">
<h2>Changes since Python 3.0<a class="headerlink" href="#changes-since-python-3-0" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li>The methods <code class="xref py py-meth docutils literal notranslate"><span class="pre">Turtle.shearfactor()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">Turtle.shapetransform()</span></code> and
<code class="xref py py-meth docutils literal notranslate"><span class="pre">Turtle.get_shapepoly()</span></code> have been added. Thus the full range of
regular linear transforms is now available for transforming turtle shapes.
<code class="xref py py-meth docutils literal notranslate"><span class="pre">Turtle.tiltangle()</span></code> has been enhanced in functionality: it now can
be used to get or set the tiltangle. <code class="xref py py-meth docutils literal notranslate"><span class="pre">Turtle.settiltangle()</span></code> has been
deprecated.</li>
<li>The method <code class="xref py py-meth docutils literal notranslate"><span class="pre">Screen.onkeypress()</span></code> has been added as a complement to
<code class="xref py py-meth docutils literal notranslate"><span class="pre">Screen.onkey()</span></code> which in fact binds actions to the keyrelease event.
Accordingly the latter has got an alias: <code class="xref py py-meth docutils literal notranslate"><span class="pre">Screen.onkeyrelease()</span></code>.</li>
<li>The method  <code class="xref py py-meth docutils literal notranslate"><span class="pre">Screen.mainloop()</span></code> has been added. So when working only
with Screen and Turtle objects one must not additionally import
<code class="xref py py-func docutils literal notranslate"><span class="pre">mainloop()</span></code> anymore.</li>
<li>Two input methods has been added <code class="xref py py-meth docutils literal notranslate"><span class="pre">Screen.textinput()</span></code> and
<code class="xref py py-meth docutils literal notranslate"><span class="pre">Screen.numinput()</span></code>. These popup input dialogs and return
strings and numbers respectively.</li>
<li>Two example scripts <code class="file docutils literal notranslate"><span class="pre">tdemo_nim.py</span></code> and <code class="file docutils literal notranslate"><span class="pre">tdemo_round_dance.py</span></code>
have been added to the <code class="file docutils literal notranslate"><span class="pre">Lib/turtledemo</span></code> directory.</li>
</ul>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#"><code class="docutils literal notranslate"><span class="pre">turtle</span></code> — Turtle graphics</a><ul>
<li><a class="reference internal" href="#introduction">Introduction</a></li>
<li><a class="reference internal" href="#overview-of-available-turtle-and-screen-methods">Overview of available Turtle and Screen methods</a><ul>
<li><a class="reference internal" href="#turtle-methods">Turtle methods</a></li>
<li><a class="reference internal" href="#methods-of-turtlescreen-screen">Methods of TurtleScreen/Screen</a></li>
</ul>
</li>
<li><a class="reference internal" href="#methods-of-rawturtle-turtle-and-corresponding-functions">Methods of RawTurtle/Turtle and corresponding functions</a><ul>
<li><a class="reference internal" href="#turtle-motion">Turtle motion</a></li>
<li><a class="reference internal" href="#tell-turtle-s-state">Tell Turtle’s state</a></li>
<li><a class="reference internal" href="#settings-for-measurement">Settings for measurement</a></li>
<li><a class="reference internal" href="#pen-control">Pen control</a><ul>
<li><a class="reference internal" href="#drawing-state">Drawing state</a></li>
<li><a class="reference internal" href="#color-control">Color control</a></li>
<li><a class="reference internal" href="#filling">Filling</a></li>
<li><a class="reference internal" href="#more-drawing-control">More drawing control</a></li>
</ul>
</li>
<li><a class="reference internal" href="#turtle-state">Turtle state</a><ul>
<li><a class="reference internal" href="#visibility">Visibility</a></li>
<li><a class="reference internal" href="#appearance">Appearance</a></li>
</ul>
</li>
<li><a class="reference internal" href="#using-events">Using events</a></li>
<li><a class="reference internal" href="#special-turtle-methods">Special Turtle methods</a></li>
<li><a class="reference internal" href="#compound-shapes">Compound shapes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#methods-of-turtlescreen-screen-and-corresponding-functions">Methods of TurtleScreen/Screen and corresponding functions</a><ul>
<li><a class="reference internal" href="#window-control">Window control</a></li>
<li><a class="reference internal" href="#animation-control">Animation control</a></li>
<li><a class="reference internal" href="#using-screen-events">Using screen events</a></li>
<li><a class="reference internal" href="#input-methods">Input methods</a></li>
<li><a class="reference internal" href="#settings-and-special-methods">Settings and special methods</a></li>
<li><a class="reference internal" href="#methods-specific-to-screen-not-inherited-from-turtlescreen">Methods specific to Screen, not inherited from TurtleScreen</a></li>
</ul>
</li>
<li><a class="reference internal" href="#public-classes">Public classes</a></li>
<li><a class="reference internal" href="#help-and-configuration">Help and configuration</a><ul>
<li><a class="reference internal" href="#how-to-use-help">How to use help</a></li>
<li><a class="reference internal" href="#translation-of-docstrings-into-different-languages">Translation of docstrings into different languages</a></li>
<li><a class="reference internal" href="#how-to-configure-screen-and-turtles">How to configure Screen and Turtles</a></li>
</ul>
</li>
<li><a class="reference internal" href="#module-turtledemo"><code class="docutils literal notranslate"><span class="pre">turtledemo</span></code> — Demo scripts</a></li>
<li><a class="reference internal" href="#changes-since-python-2-6">Changes since Python 2.6</a></li>
<li><a class="reference internal" href="#changes-since-python-3-0">Changes since Python 3.0</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="frameworks.html"
                        title="previous chapter">Program Frameworks</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="cmd.html"
                        title="next chapter"><code class="docutils literal notranslate"><span class="pre">cmd</span></code> — Support for line-oriented command interpreters</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">Report a Bug</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/3.7/Doc/library/turtle.rst"
            rel="nofollow">Show Source
        </a>
      </li>
    </ul>
  </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="cmd.html" title="cmd — Support for line-oriented command interpreters"
             >next</a> |</li>
        <li class="right" >
          <a href="frameworks.html" title="Program Frameworks"
             >previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <a href="../index.html">3.7.2 Documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="frameworks.html" >Program Frameworks</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" type="text" name="q" />
          <input type="submit" value="Go" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 2001-2019, Python Software Foundation.
    <br />
    The Python Software Foundation is a non-profit corporation.
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
    <br />
    Last updated on Jan 29, 2019.
    <a href="../bugs.html">Found a bug</a>?
    <br />
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.8.3.
    </div>

  </body>
</html>